summaryrefslogtreecommitdiff
path: root/tests/desktop/rule/matchEngine/BoolMatchEngine.cpp
blob: 99f6d99c4475a859ee84b795fc4320ae8f5aefb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <desktop/rule/matchEngine/BoolMatchEngine.hpp>

#include <gtest/gtest.h>

using namespace Desktop::Rule;

TEST(BoolMatchEngine, truthyStringOne) {
    CBoolMatchEngine engine("1");
    EXPECT_TRUE(engine.match(true));
    EXPECT_FALSE(engine.match(false));
}

TEST(BoolMatchEngine, truthyStringTrue) {
    CBoolMatchEngine engine("true");
    EXPECT_TRUE(engine.match(true));
    EXPECT_FALSE(engine.match(false));
}

TEST(BoolMatchEngine, truthyStringYes) {
    CBoolMatchEngine engine("yes");
    EXPECT_TRUE(engine.match(true));
    EXPECT_FALSE(engine.match(false));
}

TEST(BoolMatchEngine, truthyStringOn) {
    CBoolMatchEngine engine("on");
    EXPECT_TRUE(engine.match(true));
    EXPECT_FALSE(engine.match(false));
}

TEST(BoolMatchEngine, truthyCaseInsensitive) {
    CBoolMatchEngine upper("TRUE");
    EXPECT_TRUE(upper.match(true));

    CBoolMatchEngine mixed("Yes");
    EXPECT_TRUE(mixed.match(true));

    CBoolMatchEngine onUpper("ON");
    EXPECT_TRUE(onUpper.match(true));
}

TEST(BoolMatchEngine, falsyStringZero) {
    CBoolMatchEngine engine("0");
    EXPECT_TRUE(engine.match(false));
    EXPECT_FALSE(engine.match(true));
}

TEST(BoolMatchEngine, falsyStringFalse) {
    CBoolMatchEngine engine("false");
    EXPECT_TRUE(engine.match(false));
    EXPECT_FALSE(engine.match(true));
}

TEST(BoolMatchEngine, falsyStringNo) {
    CBoolMatchEngine engine("no");
    EXPECT_TRUE(engine.match(false));
    EXPECT_FALSE(engine.match(true));
}

TEST(BoolMatchEngine, falsyStringEmpty) {
    CBoolMatchEngine engine("");
    EXPECT_TRUE(engine.match(false));
    EXPECT_FALSE(engine.match(true));
}

TEST(BoolMatchEngine, falsyStringArbitrary) {
    CBoolMatchEngine engine("banana");
    EXPECT_TRUE(engine.match(false));
    EXPECT_FALSE(engine.match(true));
}