1e45d8c71SBrad Bishop #include "utils.hpp"
2481c5d5cSJames Feist 
3481c5d5cSJames Feist #include <nlohmann/json.hpp>
48c505da0SJames Feist 
59d2ef081SBrad Bishop #include <string>
6481c5d5cSJames Feist #include <variant>
7481c5d5cSJames Feist 
8481c5d5cSJames Feist #include "gtest/gtest.h"
9481c5d5cSJames Feist 
109d2ef081SBrad Bishop using namespace std::string_literals;
119d2ef081SBrad Bishop 
TEST(TemplateCharReplace,replaceOneInt)12481c5d5cSJames Feist TEST(TemplateCharReplace, replaceOneInt)
13481c5d5cSJames Feist {
14481c5d5cSJames Feist     nlohmann::json j = {{"foo", "$bus"}};
15481c5d5cSJames Feist     auto it = j.begin();
161983d2f4SAndrew Jeffery     DBusInterface data;
17481c5d5cSJames Feist     data["BUS"] = 23;
18481c5d5cSJames Feist 
19481c5d5cSJames Feist     templateCharReplace(it, data, 0);
20481c5d5cSJames Feist 
21481c5d5cSJames Feist     nlohmann::json expected = 23;
22481c5d5cSJames Feist     EXPECT_EQ(expected, j["foo"]);
23481c5d5cSJames Feist }
24481c5d5cSJames Feist 
TEST(TemplateCharReplace,replaceOneStr)25481c5d5cSJames Feist TEST(TemplateCharReplace, replaceOneStr)
26481c5d5cSJames Feist {
27481c5d5cSJames Feist     nlohmann::json j = {{"foo", "$TEST"}};
28481c5d5cSJames Feist     auto it = j.begin();
291983d2f4SAndrew Jeffery     DBusInterface data;
30481c5d5cSJames Feist     data["TEST"] = std::string("Test");
31481c5d5cSJames Feist 
32481c5d5cSJames Feist     templateCharReplace(it, data, 0);
33481c5d5cSJames Feist 
34481c5d5cSJames Feist     nlohmann::json expected = "Test";
35481c5d5cSJames Feist     EXPECT_EQ(expected, j["foo"]);
36481c5d5cSJames Feist }
37481c5d5cSJames Feist 
TEST(TemplateCharReplace,replaceSecondStr)38481c5d5cSJames Feist TEST(TemplateCharReplace, replaceSecondStr)
39481c5d5cSJames Feist {
40481c5d5cSJames Feist     nlohmann::json j = {{"foo", "the $TEST"}};
41481c5d5cSJames Feist     auto it = j.begin();
421983d2f4SAndrew Jeffery     DBusInterface data;
43481c5d5cSJames Feist     data["TEST"] = std::string("Test");
44481c5d5cSJames Feist 
45481c5d5cSJames Feist     templateCharReplace(it, data, 0);
46481c5d5cSJames Feist 
47481c5d5cSJames Feist     nlohmann::json expected = "the Test";
48481c5d5cSJames Feist     EXPECT_EQ(expected, j["foo"]);
49481c5d5cSJames Feist }
50481c5d5cSJames Feist 
TEST(TemplateCharReplace,replaceMiddleStr)51481c5d5cSJames Feist TEST(TemplateCharReplace, replaceMiddleStr)
52481c5d5cSJames Feist {
53481c5d5cSJames Feist     nlohmann::json j = {{"foo", "the $TEST worked"}};
54481c5d5cSJames Feist     auto it = j.begin();
551983d2f4SAndrew Jeffery     DBusInterface data;
56481c5d5cSJames Feist     data["TEST"] = std::string("Test");
57481c5d5cSJames Feist 
58481c5d5cSJames Feist     templateCharReplace(it, data, 0);
59481c5d5cSJames Feist 
60481c5d5cSJames Feist     nlohmann::json expected = "the Test worked";
61481c5d5cSJames Feist     EXPECT_EQ(expected, j["foo"]);
62481c5d5cSJames Feist }
63481c5d5cSJames Feist 
TEST(TemplateCharReplace,replaceLastStr)64481c5d5cSJames Feist TEST(TemplateCharReplace, replaceLastStr)
65481c5d5cSJames Feist {
66481c5d5cSJames Feist     nlohmann::json j = {{"foo", "the Test $TEST"}};
67481c5d5cSJames Feist     auto it = j.begin();
681983d2f4SAndrew Jeffery     DBusInterface data;
69481c5d5cSJames Feist     data["TEST"] = 23;
70481c5d5cSJames Feist 
71481c5d5cSJames Feist     templateCharReplace(it, data, 0);
72481c5d5cSJames Feist 
73481c5d5cSJames Feist     nlohmann::json expected = "the Test 23";
74481c5d5cSJames Feist     EXPECT_EQ(expected, j["foo"]);
75481c5d5cSJames Feist }
76481c5d5cSJames Feist 
TEST(TemplateCharReplace,increment)77481c5d5cSJames Feist TEST(TemplateCharReplace, increment)
78481c5d5cSJames Feist {
79481c5d5cSJames Feist     nlohmann::json j = {{"foo", "3 plus 1 equals $TEST + 1"}};
80481c5d5cSJames Feist     auto it = j.begin();
811983d2f4SAndrew Jeffery     DBusInterface data;
82481c5d5cSJames Feist     data["TEST"] = 3;
83481c5d5cSJames Feist 
84481c5d5cSJames Feist     templateCharReplace(it, data, 0);
85481c5d5cSJames Feist 
86481c5d5cSJames Feist     nlohmann::json expected = "3 plus 1 equals 4";
87481c5d5cSJames Feist     EXPECT_EQ(expected, j["foo"]);
88481c5d5cSJames Feist }
89481c5d5cSJames Feist 
TEST(TemplateCharReplace,decrement)90481c5d5cSJames Feist TEST(TemplateCharReplace, decrement)
91481c5d5cSJames Feist {
92481c5d5cSJames Feist     nlohmann::json j = {{"foo", "3 minus 1 equals $TEST - 1 !"}};
93481c5d5cSJames Feist     auto it = j.begin();
941983d2f4SAndrew Jeffery     DBusInterface data;
95481c5d5cSJames Feist     data["TEST"] = 3;
96481c5d5cSJames Feist 
97481c5d5cSJames Feist     templateCharReplace(it, data, 0);
98481c5d5cSJames Feist 
99481c5d5cSJames Feist     nlohmann::json expected = "3 minus 1 equals 2 !";
100481c5d5cSJames Feist     EXPECT_EQ(expected, j["foo"]);
101481c5d5cSJames Feist }
102481c5d5cSJames Feist 
TEST(TemplateCharReplace,modulus)103481c5d5cSJames Feist TEST(TemplateCharReplace, modulus)
104481c5d5cSJames Feist {
105481c5d5cSJames Feist     nlohmann::json j = {{"foo", "3 mod 2 equals $TEST % 2"}};
106481c5d5cSJames Feist     auto it = j.begin();
1071983d2f4SAndrew Jeffery     DBusInterface data;
108481c5d5cSJames Feist     data["TEST"] = 3;
109481c5d5cSJames Feist 
110481c5d5cSJames Feist     templateCharReplace(it, data, 0);
111481c5d5cSJames Feist 
112481c5d5cSJames Feist     nlohmann::json expected = "3 mod 2 equals 1";
113481c5d5cSJames Feist     EXPECT_EQ(expected, j["foo"]);
114481c5d5cSJames Feist }
115481c5d5cSJames Feist 
TEST(TemplateCharReplace,multiply)116481c5d5cSJames Feist TEST(TemplateCharReplace, multiply)
117481c5d5cSJames Feist {
118481c5d5cSJames Feist     nlohmann::json j = {{"foo", "3 * 2 equals $TEST * 2"}};
119481c5d5cSJames Feist     auto it = j.begin();
1201983d2f4SAndrew Jeffery     DBusInterface data;
121481c5d5cSJames Feist     data["TEST"] = 3;
122481c5d5cSJames Feist 
123481c5d5cSJames Feist     templateCharReplace(it, data, 0);
124481c5d5cSJames Feist 
125481c5d5cSJames Feist     nlohmann::json expected = "3 * 2 equals 6";
126481c5d5cSJames Feist     EXPECT_EQ(expected, j["foo"]);
127481c5d5cSJames Feist }
128481c5d5cSJames Feist 
TEST(TemplateCharReplace,divide)129481c5d5cSJames Feist TEST(TemplateCharReplace, divide)
130481c5d5cSJames Feist {
131481c5d5cSJames Feist     nlohmann::json j = {{"foo", "4 / 2 equals $TEST / 2"}};
132481c5d5cSJames Feist     auto it = j.begin();
1331983d2f4SAndrew Jeffery     DBusInterface data;
134481c5d5cSJames Feist     data["TEST"] = 4;
135481c5d5cSJames Feist 
136481c5d5cSJames Feist     templateCharReplace(it, data, 0);
137481c5d5cSJames Feist 
138481c5d5cSJames Feist     nlohmann::json expected = "4 / 2 equals 2";
139481c5d5cSJames Feist     EXPECT_EQ(expected, j["foo"]);
140481c5d5cSJames Feist }
1418c20febcSJames Feist 
TEST(TemplateCharReplace,multiMath)1428c20febcSJames Feist TEST(TemplateCharReplace, multiMath)
1438c20febcSJames Feist {
1448c20febcSJames Feist     nlohmann::json j = {{"foo", "4 * 2 % 6 equals $TEST * 2 % 6"}};
1458c20febcSJames Feist     auto it = j.begin();
1461983d2f4SAndrew Jeffery     DBusInterface data;
1478c20febcSJames Feist     data["TEST"] = 4;
1488c20febcSJames Feist 
1498c20febcSJames Feist     templateCharReplace(it, data, 0);
1508c20febcSJames Feist 
1518c20febcSJames Feist     nlohmann::json expected = "4 * 2 % 6 equals 2";
1528c20febcSJames Feist     EXPECT_EQ(expected, j["foo"]);
1538c20febcSJames Feist }
1548c20febcSJames Feist 
TEST(TemplateCharReplace,twoReplacements)1558c20febcSJames Feist TEST(TemplateCharReplace, twoReplacements)
1568c20febcSJames Feist {
1578c20febcSJames Feist     nlohmann::json j = {{"foo", "$FOO $BAR"}};
1588c20febcSJames Feist     auto it = j.begin();
1591983d2f4SAndrew Jeffery     DBusInterface data;
1608c20febcSJames Feist     data["FOO"] = std::string("foo");
1618c20febcSJames Feist     data["BAR"] = std::string("bar");
1628c20febcSJames Feist 
1638c20febcSJames Feist     templateCharReplace(it, data, 0);
1648c20febcSJames Feist 
1658c20febcSJames Feist     nlohmann::json expected = "foo bar";
1668c20febcSJames Feist     EXPECT_EQ(expected, j["foo"]);
1678c20febcSJames Feist }
1688c20febcSJames Feist 
TEST(TemplateCharReplace,twoReplacementsWithMath)1698c20febcSJames Feist TEST(TemplateCharReplace, twoReplacementsWithMath)
1708c20febcSJames Feist {
1718c20febcSJames Feist     nlohmann::json j = {{"foo", "4 / 2 equals $TEST / 2 $BAR"}};
1728c20febcSJames Feist     auto it = j.begin();
1731983d2f4SAndrew Jeffery     DBusInterface data;
1748c20febcSJames Feist     data["TEST"] = 4;
1758c20febcSJames Feist     data["BAR"] = std::string("bar");
1768c20febcSJames Feist 
1778c20febcSJames Feist     templateCharReplace(it, data, 0);
1788c20febcSJames Feist 
1798c20febcSJames Feist     nlohmann::json expected = "4 / 2 equals 2 bar";
180a0d1b3f8SZhikui Ren }
181a0d1b3f8SZhikui Ren 
TEST(TemplateCharReplace,twoReplacementsWithMath2)182a0d1b3f8SZhikui Ren TEST(TemplateCharReplace, twoReplacementsWithMath2)
183a0d1b3f8SZhikui Ren {
184a0d1b3f8SZhikui Ren     nlohmann::json j = {{"foo", "4 / 2 equals $ADDRESS / 2 $BAR"}};
185a0d1b3f8SZhikui Ren     auto it = j.begin();
1861983d2f4SAndrew Jeffery     DBusInterface data;
187a0d1b3f8SZhikui Ren     data["ADDRESS"] = 4;
188a0d1b3f8SZhikui Ren     data["BAR"] = std::string("bar");
189a0d1b3f8SZhikui Ren 
190a0d1b3f8SZhikui Ren     templateCharReplace(it, data, 0);
191a0d1b3f8SZhikui Ren 
192a0d1b3f8SZhikui Ren     nlohmann::json expected = "4 / 2 equals 2 bar";
1938c20febcSJames Feist     EXPECT_EQ(expected, j["foo"]);
1948c20febcSJames Feist }
195b0097d41SJames Feist 
TEST(TemplateCharReplace,hexAndWrongCase)196b0097d41SJames Feist TEST(TemplateCharReplace, hexAndWrongCase)
197b0097d41SJames Feist {
198b0097d41SJames Feist     nlohmann::json j = {{"Address", "0x54"},
199b0097d41SJames Feist                         {"Bus", 15},
200b0097d41SJames Feist                         {"Name", "$bus sensor 0"},
201b0097d41SJames Feist                         {"Type", "SomeType"}};
202b0097d41SJames Feist 
2031983d2f4SAndrew Jeffery     DBusInterface data;
204b0097d41SJames Feist     data["BUS"] = 15;
205b0097d41SJames Feist 
206b0097d41SJames Feist     for (auto it = j.begin(); it != j.end(); it++)
207b0097d41SJames Feist     {
208b0097d41SJames Feist         templateCharReplace(it, data, 0);
209b0097d41SJames Feist     }
210b0097d41SJames Feist     nlohmann::json expected = {{"Address", 84},
211b0097d41SJames Feist                                {"Bus", 15},
212b0097d41SJames Feist                                {"Name", "15 sensor 0"},
213b0097d41SJames Feist                                {"Type", "SomeType"}};
214b0097d41SJames Feist     EXPECT_EQ(expected, j);
215b0097d41SJames Feist }
216b0097d41SJames Feist 
TEST(TemplateCharReplace,replaceSecondAsInt)217b0097d41SJames Feist TEST(TemplateCharReplace, replaceSecondAsInt)
218b0097d41SJames Feist {
219b0097d41SJames Feist     nlohmann::json j = {{"foo", "twelve is $TEST"}};
220b0097d41SJames Feist     auto it = j.begin();
2211983d2f4SAndrew Jeffery     DBusInterface data;
222b0097d41SJames Feist     data["test"] = 12;
223b0097d41SJames Feist 
224b0097d41SJames Feist     templateCharReplace(it, data, 0);
225b0097d41SJames Feist 
226b0097d41SJames Feist     nlohmann::json expected = "twelve is 12";
227b0097d41SJames Feist     EXPECT_EQ(expected, j["foo"]);
228b0097d41SJames Feist }
229c296c80eSJames Feist 
TEST(TemplateCharReplace,singleHex)230c296c80eSJames Feist TEST(TemplateCharReplace, singleHex)
231c296c80eSJames Feist {
232c296c80eSJames Feist     nlohmann::json j = {{"foo", "0x54"}};
233c296c80eSJames Feist     auto it = j.begin();
2341983d2f4SAndrew Jeffery     DBusInterface data;
235c296c80eSJames Feist 
236c296c80eSJames Feist     templateCharReplace(it, data, 0);
237c296c80eSJames Feist 
238c296c80eSJames Feist     nlohmann::json expected = 84;
239c296c80eSJames Feist     EXPECT_EQ(expected, j["foo"]);
240c296c80eSJames Feist }
2419d2ef081SBrad Bishop 
TEST(MatchProbe,stringEqString)2429d2ef081SBrad Bishop TEST(MatchProbe, stringEqString)
2439d2ef081SBrad Bishop {
2449d2ef081SBrad Bishop     nlohmann::json j = R"("foo")"_json;
245eab4929dSAndrew Jeffery     DBusValueVariant v = "foo"s;
2469d2ef081SBrad Bishop     EXPECT_TRUE(matchProbe(j, v));
2479d2ef081SBrad Bishop }
2489d2ef081SBrad Bishop 
TEST(MatchProbe,stringRegexEqString)2499d2ef081SBrad Bishop TEST(MatchProbe, stringRegexEqString)
2509d2ef081SBrad Bishop {
2519d2ef081SBrad Bishop     nlohmann::json j = R"("foo*")"_json;
252eab4929dSAndrew Jeffery     DBusValueVariant v = "foobar"s;
2539d2ef081SBrad Bishop     EXPECT_TRUE(matchProbe(j, v));
2549d2ef081SBrad Bishop }
2559d2ef081SBrad Bishop 
TEST(MatchProbe,stringNeqString)2569d2ef081SBrad Bishop TEST(MatchProbe, stringNeqString)
2579d2ef081SBrad Bishop {
2589d2ef081SBrad Bishop     nlohmann::json j = R"("foobar")"_json;
259eab4929dSAndrew Jeffery     DBusValueVariant v = "foo"s;
2609d2ef081SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
2619d2ef081SBrad Bishop }
2629d2ef081SBrad Bishop 
TEST(MatchProbe,stringRegexError)2639d2ef081SBrad Bishop TEST(MatchProbe, stringRegexError)
2649d2ef081SBrad Bishop {
2659d2ef081SBrad Bishop     nlohmann::json j = R"("foo[")"_json;
266eab4929dSAndrew Jeffery     DBusValueVariant v = "foobar"s;
2675d525413SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
2689d2ef081SBrad Bishop }
2699d2ef081SBrad Bishop 
TEST(MatchProbe,stringRegexNotPrefix)270*1c39d7b8SPatrick Rudolph TEST(MatchProbe, stringRegexNotPrefix)
271*1c39d7b8SPatrick Rudolph {
272*1c39d7b8SPatrick Rudolph     nlohmann::json j = R"("foo(?!bar)...foo")"_json;
273*1c39d7b8SPatrick Rudolph     DBusValueVariant v1 = "foobarfoo"s;
274*1c39d7b8SPatrick Rudolph     DBusValueVariant v2 = "foofoofoo"s;
275*1c39d7b8SPatrick Rudolph     EXPECT_FALSE(matchProbe(j, v1));
276*1c39d7b8SPatrick Rudolph     EXPECT_TRUE(matchProbe(j, v2));
277*1c39d7b8SPatrick Rudolph }
278*1c39d7b8SPatrick Rudolph 
TEST(MatchProbe,stringZeroNeqFalse)2795d525413SBrad Bishop TEST(MatchProbe, stringZeroNeqFalse)
2809d2ef081SBrad Bishop {
2819d2ef081SBrad Bishop     nlohmann::json j = R"("0")"_json;
282eab4929dSAndrew Jeffery     DBusValueVariant v = false;
2835d525413SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
2849d2ef081SBrad Bishop }
2859d2ef081SBrad Bishop 
TEST(MatchProbe,stringOneNeqTrue)2865d525413SBrad Bishop TEST(MatchProbe, stringOneNeqTrue)
2879d2ef081SBrad Bishop {
2889d2ef081SBrad Bishop     nlohmann::json j = R"("1")"_json;
289eab4929dSAndrew Jeffery     DBusValueVariant v = true;
2905d525413SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
2919d2ef081SBrad Bishop }
2929d2ef081SBrad Bishop 
TEST(MatchProbe,stringElevenNeqTrue)2939d2ef081SBrad Bishop TEST(MatchProbe, stringElevenNeqTrue)
2949d2ef081SBrad Bishop {
2959d2ef081SBrad Bishop     nlohmann::json j = R"("11")"_json;
296eab4929dSAndrew Jeffery     DBusValueVariant v = true;
2979d2ef081SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
2989d2ef081SBrad Bishop }
2999d2ef081SBrad Bishop 
TEST(MatchProbe,stringFalseNeqFalse)3009d2ef081SBrad Bishop TEST(MatchProbe, stringFalseNeqFalse)
3019d2ef081SBrad Bishop {
3029d2ef081SBrad Bishop     nlohmann::json j = R"("false")"_json;
303eab4929dSAndrew Jeffery     DBusValueVariant v = false;
3049d2ef081SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
3059d2ef081SBrad Bishop }
3069d2ef081SBrad Bishop 
TEST(MatchProbe,stringTrueNeqTrue)3079d2ef081SBrad Bishop TEST(MatchProbe, stringTrueNeqTrue)
3089d2ef081SBrad Bishop {
3099d2ef081SBrad Bishop     nlohmann::json j = R"("true")"_json;
310eab4929dSAndrew Jeffery     DBusValueVariant v = true;
3119d2ef081SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
3129d2ef081SBrad Bishop }
3139d2ef081SBrad Bishop 
TEST(MatchProbe,stringFalseNeqTrue)3149d2ef081SBrad Bishop TEST(MatchProbe, stringFalseNeqTrue)
3159d2ef081SBrad Bishop {
3169d2ef081SBrad Bishop     nlohmann::json j = R"("false")"_json;
317eab4929dSAndrew Jeffery     DBusValueVariant v = true;
3189d2ef081SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
3199d2ef081SBrad Bishop }
3209d2ef081SBrad Bishop 
TEST(MatchProbe,stringNeqUint8)3215d525413SBrad Bishop TEST(MatchProbe, stringNeqUint8)
3229d2ef081SBrad Bishop {
3239d2ef081SBrad Bishop     nlohmann::json j = R"("255")"_json;
324eab4929dSAndrew Jeffery     DBusValueVariant v = uint8_t(255);
3255d525413SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
3269d2ef081SBrad Bishop }
3279d2ef081SBrad Bishop 
TEST(MatchProbe,stringNeqUint8Overflow)3289d2ef081SBrad Bishop TEST(MatchProbe, stringNeqUint8Overflow)
3299d2ef081SBrad Bishop {
3309d2ef081SBrad Bishop     nlohmann::json j = R"("65535")"_json;
331eab4929dSAndrew Jeffery     DBusValueVariant v = uint8_t(255);
3329d2ef081SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
3339d2ef081SBrad Bishop }
3349d2ef081SBrad Bishop 
TEST(MatchProbe,stringFalseNeqUint8Zero)3359d2ef081SBrad Bishop TEST(MatchProbe, stringFalseNeqUint8Zero)
3369d2ef081SBrad Bishop {
3379d2ef081SBrad Bishop     nlohmann::json j = R"("false")"_json;
338eab4929dSAndrew Jeffery     DBusValueVariant v = uint8_t(0);
3399d2ef081SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
3409d2ef081SBrad Bishop }
3419d2ef081SBrad Bishop 
TEST(MatchProbe,stringTrueNeqUint8Zero)3429d2ef081SBrad Bishop TEST(MatchProbe, stringTrueNeqUint8Zero)
3439d2ef081SBrad Bishop {
3449d2ef081SBrad Bishop     nlohmann::json j = R"("true")"_json;
345eab4929dSAndrew Jeffery     DBusValueVariant v = uint8_t(1);
3469d2ef081SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
3479d2ef081SBrad Bishop }
3489d2ef081SBrad Bishop 
TEST(MatchProbe,stringNeqUint32)3495d525413SBrad Bishop TEST(MatchProbe, stringNeqUint32)
3509d2ef081SBrad Bishop {
3519d2ef081SBrad Bishop     nlohmann::json j = R"("11")"_json;
352eab4929dSAndrew Jeffery     DBusValueVariant v = uint32_t(11);
3539d2ef081SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
3549d2ef081SBrad Bishop }
3559d2ef081SBrad Bishop 
TEST(MatchProbe,stringNeqInt32)3569d2ef081SBrad Bishop TEST(MatchProbe, stringNeqInt32)
3579d2ef081SBrad Bishop {
3585d525413SBrad Bishop     nlohmann::json j = R"("-11")"_json;
359eab4929dSAndrew Jeffery     DBusValueVariant v = int32_t(-11);
3609d2ef081SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
3619d2ef081SBrad Bishop }
3629d2ef081SBrad Bishop 
TEST(MatchProbe,stringRegexNeqInt32)3635d525413SBrad Bishop TEST(MatchProbe, stringRegexNeqInt32)
3649d2ef081SBrad Bishop {
3659d2ef081SBrad Bishop     nlohmann::json j = R"("1*4")"_json;
366eab4929dSAndrew Jeffery     DBusValueVariant v = int32_t(124);
3675d525413SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
3689d2ef081SBrad Bishop }
3699d2ef081SBrad Bishop 
TEST(MatchProbe,stringNeqUint64)3709d2ef081SBrad Bishop TEST(MatchProbe, stringNeqUint64)
3719d2ef081SBrad Bishop {
3729d2ef081SBrad Bishop     nlohmann::json j = R"("foo")"_json;
373eab4929dSAndrew Jeffery     DBusValueVariant v = uint64_t(65535);
3749d2ef081SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
3759d2ef081SBrad Bishop }
3769d2ef081SBrad Bishop 
TEST(MatchProbe,stringNeqDouble)3779d2ef081SBrad Bishop TEST(MatchProbe, stringNeqDouble)
3789d2ef081SBrad Bishop {
3795d525413SBrad Bishop     nlohmann::json j = R"("123.4")"_json;
380eab4929dSAndrew Jeffery     DBusValueVariant v = double(123.4);
3819d2ef081SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
3829d2ef081SBrad Bishop }
3839d2ef081SBrad Bishop 
TEST(MatchProbe,stringNeqEmpty)3849d2ef081SBrad Bishop TEST(MatchProbe, stringNeqEmpty)
3859d2ef081SBrad Bishop {
3869d2ef081SBrad Bishop     nlohmann::json j = R"("-123.4")"_json;
387eab4929dSAndrew Jeffery     DBusValueVariant v;
3889d2ef081SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
3899d2ef081SBrad Bishop }
390c5eba596SBrad Bishop 
TEST(MatchProbe,stringNeqArray)391cd1868e8SBrad Bishop TEST(MatchProbe, stringNeqArray)
392cd1868e8SBrad Bishop {
393cd1868e8SBrad Bishop     nlohmann::json j = R"("-123.4")"_json;
394eab4929dSAndrew Jeffery     DBusValueVariant v = std::vector<uint8_t>{1, 2};
395cd1868e8SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
396cd1868e8SBrad Bishop }
397cd1868e8SBrad Bishop 
TEST(MatchProbe,boolNeqString)3985d525413SBrad Bishop TEST(MatchProbe, boolNeqString)
399c5eba596SBrad Bishop {
400c5eba596SBrad Bishop     nlohmann::json j = R"(false)"_json;
401eab4929dSAndrew Jeffery     DBusValueVariant v = "false"s;
4025d525413SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
403c5eba596SBrad Bishop }
404c5eba596SBrad Bishop 
TEST(MatchProbe,trueEqTrue)405c5eba596SBrad Bishop TEST(MatchProbe, trueEqTrue)
406c5eba596SBrad Bishop {
407c5eba596SBrad Bishop     nlohmann::json j = R"(true)"_json;
408eab4929dSAndrew Jeffery     DBusValueVariant v = true;
409c5eba596SBrad Bishop     EXPECT_TRUE(matchProbe(j, v));
410c5eba596SBrad Bishop }
411c5eba596SBrad Bishop 
TEST(MatchProbe,falseEqFalse)412c5eba596SBrad Bishop TEST(MatchProbe, falseEqFalse)
413c5eba596SBrad Bishop {
414c5eba596SBrad Bishop     nlohmann::json j = R"(false)"_json;
415eab4929dSAndrew Jeffery     DBusValueVariant v = false;
416c5eba596SBrad Bishop     EXPECT_TRUE(matchProbe(j, v));
417c5eba596SBrad Bishop }
418c5eba596SBrad Bishop 
TEST(MatchProbe,trueNeqFalse)419c5eba596SBrad Bishop TEST(MatchProbe, trueNeqFalse)
420c5eba596SBrad Bishop {
421c5eba596SBrad Bishop     nlohmann::json j = R"(true)"_json;
422eab4929dSAndrew Jeffery     DBusValueVariant v = false;
423c5eba596SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
424c5eba596SBrad Bishop }
425c5eba596SBrad Bishop 
TEST(MatchProbe,trueNeqInt32Zero)426c5eba596SBrad Bishop TEST(MatchProbe, trueNeqInt32Zero)
427c5eba596SBrad Bishop {
428c5eba596SBrad Bishop     nlohmann::json j = R"(true)"_json;
429eab4929dSAndrew Jeffery     DBusValueVariant v = int32_t(0);
430c5eba596SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
431c5eba596SBrad Bishop }
432c5eba596SBrad Bishop 
TEST(MatchProbe,trueNeqInt32NegativeOne)433c5eba596SBrad Bishop TEST(MatchProbe, trueNeqInt32NegativeOne)
434c5eba596SBrad Bishop {
435c5eba596SBrad Bishop     nlohmann::json j = R"(true)"_json;
436eab4929dSAndrew Jeffery     DBusValueVariant v = int32_t(-1);
437c5eba596SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
438c5eba596SBrad Bishop }
439c5eba596SBrad Bishop 
TEST(MatchProbe,falseNeqUint32One)440c5eba596SBrad Bishop TEST(MatchProbe, falseNeqUint32One)
441c5eba596SBrad Bishop {
442c5eba596SBrad Bishop     nlohmann::json j = R"(false)"_json;
443eab4929dSAndrew Jeffery     DBusValueVariant v = uint32_t(1);
444c5eba596SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
445c5eba596SBrad Bishop }
446c5eba596SBrad Bishop 
TEST(MatchProbe,falseNeqUint32Zero)4475d525413SBrad Bishop TEST(MatchProbe, falseNeqUint32Zero)
448c5eba596SBrad Bishop {
449c5eba596SBrad Bishop     nlohmann::json j = R"(false)"_json;
450eab4929dSAndrew Jeffery     DBusValueVariant v = uint32_t(0);
4515d525413SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
452c5eba596SBrad Bishop }
453c5eba596SBrad Bishop 
TEST(MatchProbe,trueNeqDoubleNegativeOne)454c5eba596SBrad Bishop TEST(MatchProbe, trueNeqDoubleNegativeOne)
455c5eba596SBrad Bishop {
456c5eba596SBrad Bishop     nlohmann::json j = R"(true)"_json;
457eab4929dSAndrew Jeffery     DBusValueVariant v = double(-1.1);
458c5eba596SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
459c5eba596SBrad Bishop }
460c5eba596SBrad Bishop 
TEST(MatchProbe,trueNeqDoubleOne)4615d525413SBrad Bishop TEST(MatchProbe, trueNeqDoubleOne)
462c5eba596SBrad Bishop {
463c5eba596SBrad Bishop     nlohmann::json j = R"(true)"_json;
464eab4929dSAndrew Jeffery     DBusValueVariant v = double(1.0);
4655d525413SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
466c5eba596SBrad Bishop }
467c5eba596SBrad Bishop 
TEST(MatchProbe,falseNeqDoubleOne)468c5eba596SBrad Bishop TEST(MatchProbe, falseNeqDoubleOne)
469c5eba596SBrad Bishop {
470c5eba596SBrad Bishop     nlohmann::json j = R"(false)"_json;
471eab4929dSAndrew Jeffery     DBusValueVariant v = double(1.0);
472c5eba596SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
473c5eba596SBrad Bishop }
474c5eba596SBrad Bishop 
TEST(MatchProbe,falseNeqDoubleZero)4755d525413SBrad Bishop TEST(MatchProbe, falseNeqDoubleZero)
476c5eba596SBrad Bishop {
477c5eba596SBrad Bishop     nlohmann::json j = R"(false)"_json;
478eab4929dSAndrew Jeffery     DBusValueVariant v = double(0.0);
4795d525413SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
480c5eba596SBrad Bishop }
481c5eba596SBrad Bishop 
TEST(MatchProbe,falseNeqEmpty)4825d525413SBrad Bishop TEST(MatchProbe, falseNeqEmpty)
483c5eba596SBrad Bishop {
484c5eba596SBrad Bishop     nlohmann::json j = R"(false)"_json;
485eab4929dSAndrew Jeffery     DBusValueVariant v;
4865d525413SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
487c5eba596SBrad Bishop }
488c5eba596SBrad Bishop 
TEST(MatchProbe,trueNeqEmpty)4895d525413SBrad Bishop TEST(MatchProbe, trueNeqEmpty)
490c5eba596SBrad Bishop {
491c5eba596SBrad Bishop     nlohmann::json j = R"(true)"_json;
492eab4929dSAndrew Jeffery     DBusValueVariant v;
4935d525413SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
494c5eba596SBrad Bishop }
495c2af531dSBrad Bishop 
TEST(MatchProbe,trueNeqArray)496cd1868e8SBrad Bishop TEST(MatchProbe, trueNeqArray)
497cd1868e8SBrad Bishop {
498cd1868e8SBrad Bishop     nlohmann::json j = R"(true)"_json;
499eab4929dSAndrew Jeffery     DBusValueVariant v = std::vector<uint8_t>{1, 2};
500cd1868e8SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
501cd1868e8SBrad Bishop }
502cd1868e8SBrad Bishop 
TEST(MatchProbe,uintNeqString)5035d525413SBrad Bishop TEST(MatchProbe, uintNeqString)
504c2af531dSBrad Bishop {
505c2af531dSBrad Bishop     nlohmann::json j = R"(11)"_json;
506eab4929dSAndrew Jeffery     DBusValueVariant v = "11"s;
5075d525413SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
508c2af531dSBrad Bishop }
509c2af531dSBrad Bishop 
TEST(MatchProbe,uintNeqTrue)510c2af531dSBrad Bishop TEST(MatchProbe, uintNeqTrue)
511c2af531dSBrad Bishop {
5125d525413SBrad Bishop     nlohmann::json j = R"(1)"_json;
513eab4929dSAndrew Jeffery     DBusValueVariant v = true;
514c2af531dSBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
515c2af531dSBrad Bishop }
516c2af531dSBrad Bishop 
TEST(MatchProbe,uintNeqFalse)5175d525413SBrad Bishop TEST(MatchProbe, uintNeqFalse)
5185d525413SBrad Bishop {
5195d525413SBrad Bishop     nlohmann::json j = R"(0)"_json;
520eab4929dSAndrew Jeffery     DBusValueVariant v = false;
5215d525413SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
5225d525413SBrad Bishop }
5235d525413SBrad Bishop 
TEST(MatchProbe,uintEqUint8)524c2af531dSBrad Bishop TEST(MatchProbe, uintEqUint8)
525c2af531dSBrad Bishop {
526c2af531dSBrad Bishop     nlohmann::json j = R"(11)"_json;
527eab4929dSAndrew Jeffery     DBusValueVariant v = uint8_t(11);
528c2af531dSBrad Bishop     EXPECT_TRUE(matchProbe(j, v));
529c2af531dSBrad Bishop }
530c2af531dSBrad Bishop 
TEST(MatchProbe,uintNeqUint8)531c2af531dSBrad Bishop TEST(MatchProbe, uintNeqUint8)
532c2af531dSBrad Bishop {
533c2af531dSBrad Bishop     nlohmann::json j = R"(11)"_json;
534eab4929dSAndrew Jeffery     DBusValueVariant v = uint8_t(12);
535c2af531dSBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
536c2af531dSBrad Bishop }
537c2af531dSBrad Bishop 
TEST(MatchProbe,uintNeqUint8Overflow)538c2af531dSBrad Bishop TEST(MatchProbe, uintNeqUint8Overflow)
539c2af531dSBrad Bishop {
540c2af531dSBrad Bishop     nlohmann::json j = R"(65535)"_json;
541eab4929dSAndrew Jeffery     DBusValueVariant v = uint8_t(255);
542c2af531dSBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
543c2af531dSBrad Bishop }
544c2af531dSBrad Bishop 
TEST(MatchProbe,uintEqInt8)545c2af531dSBrad Bishop TEST(MatchProbe, uintEqInt8)
546c2af531dSBrad Bishop {
547c2af531dSBrad Bishop     nlohmann::json j = R"(11)"_json;
548eab4929dSAndrew Jeffery     DBusValueVariant v = int8_t(11);
549c2af531dSBrad Bishop     EXPECT_TRUE(matchProbe(j, v));
550c2af531dSBrad Bishop }
551c2af531dSBrad Bishop 
TEST(MatchProbe,uintEqDouble)552c2af531dSBrad Bishop TEST(MatchProbe, uintEqDouble)
553c2af531dSBrad Bishop {
554c2af531dSBrad Bishop     nlohmann::json j = R"(11)"_json;
555eab4929dSAndrew Jeffery     DBusValueVariant v = double(11.0);
556c2af531dSBrad Bishop     EXPECT_TRUE(matchProbe(j, v));
557c2af531dSBrad Bishop }
558c2af531dSBrad Bishop 
TEST(MatchProbe,uintNeqDouble)5595d525413SBrad Bishop TEST(MatchProbe, uintNeqDouble)
560c2af531dSBrad Bishop {
561c2af531dSBrad Bishop     nlohmann::json j = R"(11)"_json;
562eab4929dSAndrew Jeffery     DBusValueVariant v = double(11.7);
5635d525413SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
564c2af531dSBrad Bishop }
565c2af531dSBrad Bishop 
TEST(MatchProbe,uintNeqEmpty)5665d525413SBrad Bishop TEST(MatchProbe, uintNeqEmpty)
567c2af531dSBrad Bishop {
568c2af531dSBrad Bishop     nlohmann::json j = R"(11)"_json;
569eab4929dSAndrew Jeffery     DBusValueVariant v;
5705d525413SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
571c2af531dSBrad Bishop }
572667e050dSBrad Bishop 
TEST(MatchProbe,uintNeqArray)573cd1868e8SBrad Bishop TEST(MatchProbe, uintNeqArray)
574cd1868e8SBrad Bishop {
575cd1868e8SBrad Bishop     nlohmann::json j = R"(11)"_json;
576eab4929dSAndrew Jeffery     DBusValueVariant v = std::vector<uint8_t>{11};
577cd1868e8SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
578cd1868e8SBrad Bishop }
579cd1868e8SBrad Bishop 
TEST(MatchProbe,intNeqString)5805d525413SBrad Bishop TEST(MatchProbe, intNeqString)
581667e050dSBrad Bishop {
582667e050dSBrad Bishop     nlohmann::json j = R"(-11)"_json;
583eab4929dSAndrew Jeffery     DBusValueVariant v = "-11"s;
5845d525413SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
585667e050dSBrad Bishop }
586667e050dSBrad Bishop 
TEST(MatchProbe,intNeqTrue)587667e050dSBrad Bishop TEST(MatchProbe, intNeqTrue)
588667e050dSBrad Bishop {
589667e050dSBrad Bishop     nlohmann::json j = R"(-1)"_json;
590eab4929dSAndrew Jeffery     DBusValueVariant v = true;
591667e050dSBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
592667e050dSBrad Bishop }
593667e050dSBrad Bishop 
TEST(MatchProbe,intNeqUint8)594667e050dSBrad Bishop TEST(MatchProbe, intNeqUint8)
595667e050dSBrad Bishop {
596667e050dSBrad Bishop     nlohmann::json j = R"(-11)"_json;
597eab4929dSAndrew Jeffery     DBusValueVariant v = uint8_t(11);
598667e050dSBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
599667e050dSBrad Bishop }
600667e050dSBrad Bishop 
TEST(MatchProbe,intEqInt8)601667e050dSBrad Bishop TEST(MatchProbe, intEqInt8)
602667e050dSBrad Bishop {
603667e050dSBrad Bishop     nlohmann::json j = R"(-11)"_json;
604eab4929dSAndrew Jeffery     DBusValueVariant v = int8_t(-11);
605667e050dSBrad Bishop     EXPECT_TRUE(matchProbe(j, v));
606667e050dSBrad Bishop }
607667e050dSBrad Bishop 
TEST(MatchProbe,intNeqDouble)608667e050dSBrad Bishop TEST(MatchProbe, intNeqDouble)
609667e050dSBrad Bishop {
610667e050dSBrad Bishop     nlohmann::json j = R"(-124)"_json;
611eab4929dSAndrew Jeffery     DBusValueVariant v = double(-123.0);
612667e050dSBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
613667e050dSBrad Bishop }
614667e050dSBrad Bishop 
TEST(MatchProbe,intEqDouble)615667e050dSBrad Bishop TEST(MatchProbe, intEqDouble)
616667e050dSBrad Bishop {
617667e050dSBrad Bishop     nlohmann::json j = R"(-11)"_json;
618eab4929dSAndrew Jeffery     DBusValueVariant v = double(-11.0);
619667e050dSBrad Bishop     EXPECT_TRUE(matchProbe(j, v));
620667e050dSBrad Bishop }
621667e050dSBrad Bishop 
TEST(MatchProbe,intNeqDoubleRound)6225d525413SBrad Bishop TEST(MatchProbe, intNeqDoubleRound)
623667e050dSBrad Bishop {
624667e050dSBrad Bishop     nlohmann::json j = R"(-11)"_json;
625eab4929dSAndrew Jeffery     DBusValueVariant v = double(-11.7);
6265d525413SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
627667e050dSBrad Bishop }
628667e050dSBrad Bishop 
TEST(MatchProbe,intNeqEmpty)6295d525413SBrad Bishop TEST(MatchProbe, intNeqEmpty)
630667e050dSBrad Bishop {
631667e050dSBrad Bishop     nlohmann::json j = R"(-11)"_json;
632eab4929dSAndrew Jeffery     DBusValueVariant v;
6335d525413SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
634667e050dSBrad Bishop }
6353bd8e8d6SBrad Bishop 
TEST(MatchProbe,intNeqArray)636cd1868e8SBrad Bishop TEST(MatchProbe, intNeqArray)
637cd1868e8SBrad Bishop {
638cd1868e8SBrad Bishop     nlohmann::json j = R"(-11)"_json;
639eab4929dSAndrew Jeffery     DBusValueVariant v = std::vector<uint8_t>{11};
640cd1868e8SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
641cd1868e8SBrad Bishop }
642cd1868e8SBrad Bishop 
TEST(MatchProbe,doubleNeqString)6435d525413SBrad Bishop TEST(MatchProbe, doubleNeqString)
6443bd8e8d6SBrad Bishop {
6453bd8e8d6SBrad Bishop     nlohmann::json j = R"(0.0)"_json;
646eab4929dSAndrew Jeffery     DBusValueVariant v = "0.0"s;
6475d525413SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
6483bd8e8d6SBrad Bishop }
6493bd8e8d6SBrad Bishop 
TEST(MatchProbe,doubleNeqFalse)6505d525413SBrad Bishop TEST(MatchProbe, doubleNeqFalse)
6513bd8e8d6SBrad Bishop {
6523bd8e8d6SBrad Bishop     nlohmann::json j = R"(0.0)"_json;
653eab4929dSAndrew Jeffery     DBusValueVariant v = false;
6545d525413SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
6553bd8e8d6SBrad Bishop }
6563bd8e8d6SBrad Bishop 
TEST(MatchProbe,doubleNeqTrue)6573bd8e8d6SBrad Bishop TEST(MatchProbe, doubleNeqTrue)
6583bd8e8d6SBrad Bishop {
6593bd8e8d6SBrad Bishop     nlohmann::json j = R"(1.0)"_json;
660eab4929dSAndrew Jeffery     DBusValueVariant v = true;
6615d525413SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
6623bd8e8d6SBrad Bishop }
6633bd8e8d6SBrad Bishop 
TEST(MatchProbe,doubleEqInt32)6643bd8e8d6SBrad Bishop TEST(MatchProbe, doubleEqInt32)
6653bd8e8d6SBrad Bishop {
6663bd8e8d6SBrad Bishop     nlohmann::json j = R"(-124.0)"_json;
667eab4929dSAndrew Jeffery     DBusValueVariant v = int32_t(-124);
6683bd8e8d6SBrad Bishop     EXPECT_TRUE(matchProbe(j, v));
6693bd8e8d6SBrad Bishop }
6703bd8e8d6SBrad Bishop 
TEST(MatchProbe,doubleNeqInt32)6713bd8e8d6SBrad Bishop TEST(MatchProbe, doubleNeqInt32)
6723bd8e8d6SBrad Bishop {
6733bd8e8d6SBrad Bishop     nlohmann::json j = R"(-124.0)"_json;
674eab4929dSAndrew Jeffery     DBusValueVariant v = int32_t(-123);
6753bd8e8d6SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
6763bd8e8d6SBrad Bishop }
6773bd8e8d6SBrad Bishop 
TEST(MatchProbe,doubleRoundNeqInt)6783bd8e8d6SBrad Bishop TEST(MatchProbe, doubleRoundNeqInt)
6793bd8e8d6SBrad Bishop {
6803bd8e8d6SBrad Bishop     nlohmann::json j = R"(124.7)"_json;
681eab4929dSAndrew Jeffery     DBusValueVariant v = int32_t(124);
6823bd8e8d6SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
6833bd8e8d6SBrad Bishop }
TEST(MatchProbe,doubleEqDouble)6843bd8e8d6SBrad Bishop TEST(MatchProbe, doubleEqDouble)
6853bd8e8d6SBrad Bishop {
6863bd8e8d6SBrad Bishop     nlohmann::json j = R"(-124.2)"_json;
687eab4929dSAndrew Jeffery     DBusValueVariant v = double(-124.2);
6883bd8e8d6SBrad Bishop     EXPECT_TRUE(matchProbe(j, v));
6893bd8e8d6SBrad Bishop }
6903bd8e8d6SBrad Bishop 
TEST(MatchProbe,doubleNeqDouble)6913bd8e8d6SBrad Bishop TEST(MatchProbe, doubleNeqDouble)
6923bd8e8d6SBrad Bishop {
6933bd8e8d6SBrad Bishop     nlohmann::json j = R"(-124.3)"_json;
694eab4929dSAndrew Jeffery     DBusValueVariant v = double(-124.2);
6953bd8e8d6SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
6963bd8e8d6SBrad Bishop }
6973bd8e8d6SBrad Bishop 
TEST(MatchProbe,doubleNeqEmpty)6985d525413SBrad Bishop TEST(MatchProbe, doubleNeqEmpty)
6993bd8e8d6SBrad Bishop {
7003bd8e8d6SBrad Bishop     nlohmann::json j = R"(-11.0)"_json;
701eab4929dSAndrew Jeffery     DBusValueVariant v;
7025d525413SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
7033bd8e8d6SBrad Bishop }
704d14c2e21SBrad Bishop 
TEST(MatchProbe,doubleNeqArray)705cd1868e8SBrad Bishop TEST(MatchProbe, doubleNeqArray)
706cd1868e8SBrad Bishop {
707cd1868e8SBrad Bishop     nlohmann::json j = R"(-11.2)"_json;
708eab4929dSAndrew Jeffery     DBusValueVariant v = std::vector<uint8_t>{11};
709cd1868e8SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
710cd1868e8SBrad Bishop }
711cd1868e8SBrad Bishop 
TEST(MatchProbe,arrayNeqString)712d14c2e21SBrad Bishop TEST(MatchProbe, arrayNeqString)
713d14c2e21SBrad Bishop {
714d14c2e21SBrad Bishop     nlohmann::json j = R"([1, 2])"_json;
715eab4929dSAndrew Jeffery     DBusValueVariant v = "hello"s;
716d14c2e21SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
717d14c2e21SBrad Bishop }
718d14c2e21SBrad Bishop 
TEST(MatchProbe,arrayNeqFalse)719d14c2e21SBrad Bishop TEST(MatchProbe, arrayNeqFalse)
720d14c2e21SBrad Bishop {
721d14c2e21SBrad Bishop     nlohmann::json j = R"([1, 2])"_json;
722eab4929dSAndrew Jeffery     DBusValueVariant v = false;
723d14c2e21SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
724d14c2e21SBrad Bishop }
725d14c2e21SBrad Bishop 
TEST(MatchProbe,arrayNeqTrue)726d14c2e21SBrad Bishop TEST(MatchProbe, arrayNeqTrue)
727d14c2e21SBrad Bishop {
728d14c2e21SBrad Bishop     nlohmann::json j = R"([1, 2])"_json;
729eab4929dSAndrew Jeffery     DBusValueVariant v = true;
730d14c2e21SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
731d14c2e21SBrad Bishop }
732d14c2e21SBrad Bishop 
TEST(MatchProbe,arrayNeqUint8)733d14c2e21SBrad Bishop TEST(MatchProbe, arrayNeqUint8)
734d14c2e21SBrad Bishop {
735d14c2e21SBrad Bishop     nlohmann::json j = R"([1, 2])"_json;
736eab4929dSAndrew Jeffery     DBusValueVariant v = uint8_t(1);
737d14c2e21SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
738d14c2e21SBrad Bishop }
739d14c2e21SBrad Bishop 
TEST(MatchProbe,arrayNeqInt32)740d14c2e21SBrad Bishop TEST(MatchProbe, arrayNeqInt32)
741d14c2e21SBrad Bishop {
742d14c2e21SBrad Bishop     nlohmann::json j = R"([1, 2])"_json;
743eab4929dSAndrew Jeffery     DBusValueVariant v = int32_t(-1);
744d14c2e21SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
745d14c2e21SBrad Bishop }
746d14c2e21SBrad Bishop 
TEST(MatchProbe,arrayNeqDouble)747d14c2e21SBrad Bishop TEST(MatchProbe, arrayNeqDouble)
748d14c2e21SBrad Bishop {
749d14c2e21SBrad Bishop     nlohmann::json j = R"([1, 2])"_json;
750eab4929dSAndrew Jeffery     DBusValueVariant v = double(1.1);
751d14c2e21SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
752d14c2e21SBrad Bishop }
7536660e2a2SBrad Bishop 
TEST(MatchProbe,arrayEqArray)754cd1868e8SBrad Bishop TEST(MatchProbe, arrayEqArray)
755cd1868e8SBrad Bishop {
756cd1868e8SBrad Bishop     nlohmann::json j = R"([1, 2])"_json;
757eab4929dSAndrew Jeffery     DBusValueVariant v = std::vector<uint8_t>{1, 2};
758cd1868e8SBrad Bishop     EXPECT_TRUE(matchProbe(j, v));
759cd1868e8SBrad Bishop }
760cd1868e8SBrad Bishop 
TEST(MatchProbe,arrayNeqArrayDiffSize1)761cd1868e8SBrad Bishop TEST(MatchProbe, arrayNeqArrayDiffSize1)
762cd1868e8SBrad Bishop {
763cd1868e8SBrad Bishop     nlohmann::json j = R"([1, 2, 3])"_json;
764eab4929dSAndrew Jeffery     DBusValueVariant v = std::vector<uint8_t>{1, 2};
765cd1868e8SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
766cd1868e8SBrad Bishop }
767cd1868e8SBrad Bishop 
TEST(MatchProbe,arrayNeqArrayDiffSize2)768cd1868e8SBrad Bishop TEST(MatchProbe, arrayNeqArrayDiffSize2)
769cd1868e8SBrad Bishop {
770cd1868e8SBrad Bishop     nlohmann::json j = R"([1, 2])"_json;
771eab4929dSAndrew Jeffery     DBusValueVariant v = std::vector<uint8_t>{1, 2, 3};
772cd1868e8SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
773cd1868e8SBrad Bishop }
774cd1868e8SBrad Bishop 
TEST(MatchProbe,emptyArrayEqEmptyArray)775cd1868e8SBrad Bishop TEST(MatchProbe, emptyArrayEqEmptyArray)
776cd1868e8SBrad Bishop {
777cd1868e8SBrad Bishop     nlohmann::json j = R"([])"_json;
778eab4929dSAndrew Jeffery     DBusValueVariant v = std::vector<uint8_t>{};
779cd1868e8SBrad Bishop     EXPECT_TRUE(matchProbe(j, v));
780cd1868e8SBrad Bishop }
781cd1868e8SBrad Bishop 
TEST(MatchProbe,emptyArrayNeqArray)782cd1868e8SBrad Bishop TEST(MatchProbe, emptyArrayNeqArray)
783cd1868e8SBrad Bishop {
784cd1868e8SBrad Bishop     nlohmann::json j = R"([])"_json;
785eab4929dSAndrew Jeffery     DBusValueVariant v = std::vector<uint8_t>{1};
786cd1868e8SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
787cd1868e8SBrad Bishop }
788cd1868e8SBrad Bishop 
TEST(MatchProbe,arrayNeqEmptyArray)789cd1868e8SBrad Bishop TEST(MatchProbe, arrayNeqEmptyArray)
790cd1868e8SBrad Bishop {
791cd1868e8SBrad Bishop     nlohmann::json j = R"([1])"_json;
792eab4929dSAndrew Jeffery     DBusValueVariant v = std::vector<uint8_t>{};
793cd1868e8SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
794cd1868e8SBrad Bishop }
795cd1868e8SBrad Bishop 
TEST(MatchProbe,objNeqString)7966660e2a2SBrad Bishop TEST(MatchProbe, objNeqString)
7976660e2a2SBrad Bishop {
7986660e2a2SBrad Bishop     nlohmann::json j = R"({"foo": "bar"})"_json;
799eab4929dSAndrew Jeffery     DBusValueVariant v = "hello"s;
8006660e2a2SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
8016660e2a2SBrad Bishop }
8026660e2a2SBrad Bishop 
TEST(MatchProbe,objNeqFalse)8036660e2a2SBrad Bishop TEST(MatchProbe, objNeqFalse)
8046660e2a2SBrad Bishop {
8056660e2a2SBrad Bishop     nlohmann::json j = R"({"foo": "bar"})"_json;
806eab4929dSAndrew Jeffery     DBusValueVariant v = false;
8076660e2a2SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
8086660e2a2SBrad Bishop }
8096660e2a2SBrad Bishop 
TEST(MatchProbe,objNeqTrue)8106660e2a2SBrad Bishop TEST(MatchProbe, objNeqTrue)
8116660e2a2SBrad Bishop {
8126660e2a2SBrad Bishop     nlohmann::json j = R"({"foo": "bar"})"_json;
813eab4929dSAndrew Jeffery     DBusValueVariant v = true;
8146660e2a2SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
8156660e2a2SBrad Bishop }
8166660e2a2SBrad Bishop 
TEST(MatchProbe,objNeqUint8)8176660e2a2SBrad Bishop TEST(MatchProbe, objNeqUint8)
8186660e2a2SBrad Bishop {
8196660e2a2SBrad Bishop     nlohmann::json j = R"({"foo": "bar"})"_json;
820eab4929dSAndrew Jeffery     DBusValueVariant v = uint8_t(1);
8216660e2a2SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
8226660e2a2SBrad Bishop }
8236660e2a2SBrad Bishop 
TEST(MatchProbe,objNeqInt32)8246660e2a2SBrad Bishop TEST(MatchProbe, objNeqInt32)
8256660e2a2SBrad Bishop {
8266660e2a2SBrad Bishop     nlohmann::json j = R"({"foo": "bar"})"_json;
827eab4929dSAndrew Jeffery     DBusValueVariant v = int32_t(-1);
8286660e2a2SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
8296660e2a2SBrad Bishop }
8306660e2a2SBrad Bishop 
TEST(MatchProbe,objNeqDouble)8316660e2a2SBrad Bishop TEST(MatchProbe, objNeqDouble)
8326660e2a2SBrad Bishop {
8336660e2a2SBrad Bishop     nlohmann::json j = R"({"foo": "bar"})"_json;
834eab4929dSAndrew Jeffery     DBusValueVariant v = double(1.1);
8356660e2a2SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
8366660e2a2SBrad Bishop }
837c776c414SBrad Bishop 
TEST(MatchProbe,objNeqArray)838cd1868e8SBrad Bishop TEST(MatchProbe, objNeqArray)
839cd1868e8SBrad Bishop {
840cd1868e8SBrad Bishop     nlohmann::json j = R"({"foo": "bar"})"_json;
841eab4929dSAndrew Jeffery     DBusValueVariant v = std::vector<uint8_t>{1, 2};
842cd1868e8SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
843cd1868e8SBrad Bishop }
844cd1868e8SBrad Bishop 
TEST(MatchProbe,nullNeqString)845c776c414SBrad Bishop TEST(MatchProbe, nullNeqString)
846c776c414SBrad Bishop {
847c776c414SBrad Bishop     nlohmann::json j = R"(null)"_json;
848eab4929dSAndrew Jeffery     DBusValueVariant v = "hello"s;
849c776c414SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
850c776c414SBrad Bishop }
851c776c414SBrad Bishop 
TEST(MatchProbe,nullNeqFalse)852c776c414SBrad Bishop TEST(MatchProbe, nullNeqFalse)
853c776c414SBrad Bishop {
854c776c414SBrad Bishop     nlohmann::json j = R"(null)"_json;
855eab4929dSAndrew Jeffery     DBusValueVariant v = false;
856c776c414SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
857c776c414SBrad Bishop }
858c776c414SBrad Bishop 
TEST(MatchProbe,nullNeqTrue)859c776c414SBrad Bishop TEST(MatchProbe, nullNeqTrue)
860c776c414SBrad Bishop {
861c776c414SBrad Bishop     nlohmann::json j = R"(null)"_json;
862eab4929dSAndrew Jeffery     DBusValueVariant v = true;
863c776c414SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
864c776c414SBrad Bishop }
865c776c414SBrad Bishop 
TEST(MatchProbe,nullNeqUint8)866c776c414SBrad Bishop TEST(MatchProbe, nullNeqUint8)
867c776c414SBrad Bishop {
868c776c414SBrad Bishop     nlohmann::json j = R"(null)"_json;
869eab4929dSAndrew Jeffery     DBusValueVariant v = uint8_t(1);
870c776c414SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
871c776c414SBrad Bishop }
872c776c414SBrad Bishop 
TEST(MatchProbe,nullNeqInt32)873c776c414SBrad Bishop TEST(MatchProbe, nullNeqInt32)
874c776c414SBrad Bishop {
875c776c414SBrad Bishop     nlohmann::json j = R"(null)"_json;
876eab4929dSAndrew Jeffery     DBusValueVariant v = int32_t(-1);
877c776c414SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
878c776c414SBrad Bishop }
879c776c414SBrad Bishop 
TEST(MatchProbe,nullNeqDouble)880c776c414SBrad Bishop TEST(MatchProbe, nullNeqDouble)
881c776c414SBrad Bishop {
882c776c414SBrad Bishop     nlohmann::json j = R"(null)"_json;
883eab4929dSAndrew Jeffery     DBusValueVariant v = double(1.1);
884c776c414SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
885c776c414SBrad Bishop }
886cd1868e8SBrad Bishop 
TEST(MatchProbe,nullNeqArray)887cd1868e8SBrad Bishop TEST(MatchProbe, nullNeqArray)
888cd1868e8SBrad Bishop {
889cd1868e8SBrad Bishop     nlohmann::json j = R"(null)"_json;
890eab4929dSAndrew Jeffery     DBusValueVariant v = std::vector<uint8_t>{};
891cd1868e8SBrad Bishop     EXPECT_FALSE(matchProbe(j, v));
892cd1868e8SBrad Bishop }
893