blob: 796609024f8e3176f22154b1f4ab0390360bcb82 [file] [log] [blame]
Christopher Meis59ef1e72025-04-16 08:53:25 +02001#include "entity_manager/utils.hpp"
Brad Bishope45d8c72022-05-25 15:12:53 -04002#include "utils.hpp"
James Feist481c5d52019-08-13 14:40:40 -07003
James Feist481c5d52019-08-13 14:40:40 -07004#include <nlohmann/json.hpp>
James Feist8c505da2020-05-28 10:06:33 -07005
Brad Bishop9d2ef082020-08-26 15:17:55 -04006#include <string>
James Feist481c5d52019-08-13 14:40:40 -07007#include <variant>
8
9#include "gtest/gtest.h"
10
Brad Bishop9d2ef082020-08-26 15:17:55 -040011using namespace std::string_literals;
12
James Feist481c5d52019-08-13 14:40:40 -070013TEST(TemplateCharReplace, replaceOneInt)
14{
15 nlohmann::json j = {{"foo", "$bus"}};
16 auto it = j.begin();
Andrew Jeffery1983d2f2022-04-05 14:55:13 +093017 DBusInterface data;
James Feist481c5d52019-08-13 14:40:40 -070018 data["BUS"] = 23;
19
Christopher Meis59ef1e72025-04-16 08:53:25 +020020 em_utils::templateCharReplace(it, data, 0);
James Feist481c5d52019-08-13 14:40:40 -070021
22 nlohmann::json expected = 23;
23 EXPECT_EQ(expected, j["foo"]);
24}
25
26TEST(TemplateCharReplace, replaceOneStr)
27{
28 nlohmann::json j = {{"foo", "$TEST"}};
29 auto it = j.begin();
Andrew Jeffery1983d2f2022-04-05 14:55:13 +093030 DBusInterface data;
James Feist481c5d52019-08-13 14:40:40 -070031 data["TEST"] = std::string("Test");
32
Christopher Meis59ef1e72025-04-16 08:53:25 +020033 em_utils::templateCharReplace(it, data, 0);
James Feist481c5d52019-08-13 14:40:40 -070034
35 nlohmann::json expected = "Test";
36 EXPECT_EQ(expected, j["foo"]);
37}
38
39TEST(TemplateCharReplace, replaceSecondStr)
40{
41 nlohmann::json j = {{"foo", "the $TEST"}};
42 auto it = j.begin();
Andrew Jeffery1983d2f2022-04-05 14:55:13 +093043 DBusInterface data;
James Feist481c5d52019-08-13 14:40:40 -070044 data["TEST"] = std::string("Test");
45
Christopher Meis59ef1e72025-04-16 08:53:25 +020046 em_utils::templateCharReplace(it, data, 0);
James Feist481c5d52019-08-13 14:40:40 -070047
48 nlohmann::json expected = "the Test";
49 EXPECT_EQ(expected, j["foo"]);
50}
51
James Feist481c5d52019-08-13 14:40:40 -070052TEST(TemplateCharReplace, replaceMiddleStr)
53{
54 nlohmann::json j = {{"foo", "the $TEST worked"}};
55 auto it = j.begin();
Andrew Jeffery1983d2f2022-04-05 14:55:13 +093056 DBusInterface data;
James Feist481c5d52019-08-13 14:40:40 -070057 data["TEST"] = std::string("Test");
58
Christopher Meis59ef1e72025-04-16 08:53:25 +020059 em_utils::templateCharReplace(it, data, 0);
James Feist481c5d52019-08-13 14:40:40 -070060
61 nlohmann::json expected = "the Test worked";
62 EXPECT_EQ(expected, j["foo"]);
63}
James Feist481c5d52019-08-13 14:40:40 -070064
65TEST(TemplateCharReplace, replaceLastStr)
66{
67 nlohmann::json j = {{"foo", "the Test $TEST"}};
68 auto it = j.begin();
Andrew Jeffery1983d2f2022-04-05 14:55:13 +093069 DBusInterface data;
James Feist481c5d52019-08-13 14:40:40 -070070 data["TEST"] = 23;
71
Christopher Meis59ef1e72025-04-16 08:53:25 +020072 em_utils::templateCharReplace(it, data, 0);
James Feist481c5d52019-08-13 14:40:40 -070073
74 nlohmann::json expected = "the Test 23";
75 EXPECT_EQ(expected, j["foo"]);
76}
77
78TEST(TemplateCharReplace, increment)
79{
80 nlohmann::json j = {{"foo", "3 plus 1 equals $TEST + 1"}};
81 auto it = j.begin();
Andrew Jeffery1983d2f2022-04-05 14:55:13 +093082 DBusInterface data;
James Feist481c5d52019-08-13 14:40:40 -070083 data["TEST"] = 3;
84
Christopher Meis59ef1e72025-04-16 08:53:25 +020085 em_utils::templateCharReplace(it, data, 0);
James Feist481c5d52019-08-13 14:40:40 -070086
87 nlohmann::json expected = "3 plus 1 equals 4";
88 EXPECT_EQ(expected, j["foo"]);
89}
90
91TEST(TemplateCharReplace, decrement)
92{
93 nlohmann::json j = {{"foo", "3 minus 1 equals $TEST - 1 !"}};
94 auto it = j.begin();
Andrew Jeffery1983d2f2022-04-05 14:55:13 +093095 DBusInterface data;
James Feist481c5d52019-08-13 14:40:40 -070096 data["TEST"] = 3;
97
Christopher Meis59ef1e72025-04-16 08:53:25 +020098 em_utils::templateCharReplace(it, data, 0);
James Feist481c5d52019-08-13 14:40:40 -070099
100 nlohmann::json expected = "3 minus 1 equals 2 !";
101 EXPECT_EQ(expected, j["foo"]);
102}
103
104TEST(TemplateCharReplace, modulus)
105{
106 nlohmann::json j = {{"foo", "3 mod 2 equals $TEST % 2"}};
107 auto it = j.begin();
Andrew Jeffery1983d2f2022-04-05 14:55:13 +0930108 DBusInterface data;
James Feist481c5d52019-08-13 14:40:40 -0700109 data["TEST"] = 3;
110
Christopher Meis59ef1e72025-04-16 08:53:25 +0200111 em_utils::templateCharReplace(it, data, 0);
James Feist481c5d52019-08-13 14:40:40 -0700112
113 nlohmann::json expected = "3 mod 2 equals 1";
114 EXPECT_EQ(expected, j["foo"]);
115}
116
117TEST(TemplateCharReplace, multiply)
118{
119 nlohmann::json j = {{"foo", "3 * 2 equals $TEST * 2"}};
120 auto it = j.begin();
Andrew Jeffery1983d2f2022-04-05 14:55:13 +0930121 DBusInterface data;
James Feist481c5d52019-08-13 14:40:40 -0700122 data["TEST"] = 3;
123
Christopher Meis59ef1e72025-04-16 08:53:25 +0200124 em_utils::templateCharReplace(it, data, 0);
James Feist481c5d52019-08-13 14:40:40 -0700125
126 nlohmann::json expected = "3 * 2 equals 6";
127 EXPECT_EQ(expected, j["foo"]);
128}
129
130TEST(TemplateCharReplace, divide)
131{
132 nlohmann::json j = {{"foo", "4 / 2 equals $TEST / 2"}};
133 auto it = j.begin();
Andrew Jeffery1983d2f2022-04-05 14:55:13 +0930134 DBusInterface data;
James Feist481c5d52019-08-13 14:40:40 -0700135 data["TEST"] = 4;
136
Christopher Meis59ef1e72025-04-16 08:53:25 +0200137 em_utils::templateCharReplace(it, data, 0);
James Feist481c5d52019-08-13 14:40:40 -0700138
139 nlohmann::json expected = "4 / 2 equals 2";
140 EXPECT_EQ(expected, j["foo"]);
James Feist8c20feb2019-08-14 15:10:11 -0700141}
142
143TEST(TemplateCharReplace, multiMath)
144{
145 nlohmann::json j = {{"foo", "4 * 2 % 6 equals $TEST * 2 % 6"}};
146 auto it = j.begin();
Andrew Jeffery1983d2f2022-04-05 14:55:13 +0930147 DBusInterface data;
James Feist8c20feb2019-08-14 15:10:11 -0700148 data["TEST"] = 4;
149
Christopher Meis59ef1e72025-04-16 08:53:25 +0200150 em_utils::templateCharReplace(it, data, 0);
James Feist8c20feb2019-08-14 15:10:11 -0700151
152 nlohmann::json expected = "4 * 2 % 6 equals 2";
153 EXPECT_EQ(expected, j["foo"]);
154}
155
156TEST(TemplateCharReplace, twoReplacements)
157{
158 nlohmann::json j = {{"foo", "$FOO $BAR"}};
159 auto it = j.begin();
Andrew Jeffery1983d2f2022-04-05 14:55:13 +0930160 DBusInterface data;
James Feist8c20feb2019-08-14 15:10:11 -0700161 data["FOO"] = std::string("foo");
162 data["BAR"] = std::string("bar");
163
Christopher Meis59ef1e72025-04-16 08:53:25 +0200164 em_utils::templateCharReplace(it, data, 0);
James Feist8c20feb2019-08-14 15:10:11 -0700165
166 nlohmann::json expected = "foo bar";
167 EXPECT_EQ(expected, j["foo"]);
168}
169
170TEST(TemplateCharReplace, twoReplacementsWithMath)
171{
172 nlohmann::json j = {{"foo", "4 / 2 equals $TEST / 2 $BAR"}};
173 auto it = j.begin();
Andrew Jeffery1983d2f2022-04-05 14:55:13 +0930174 DBusInterface data;
James Feist8c20feb2019-08-14 15:10:11 -0700175 data["TEST"] = 4;
176 data["BAR"] = std::string("bar");
177
Christopher Meis59ef1e72025-04-16 08:53:25 +0200178 em_utils::templateCharReplace(it, data, 0);
James Feist8c20feb2019-08-14 15:10:11 -0700179
180 nlohmann::json expected = "4 / 2 equals 2 bar";
Zhikui Rena0d1b3f2021-10-05 16:21:56 -0700181}
182
183TEST(TemplateCharReplace, twoReplacementsWithMath2)
184{
185 nlohmann::json j = {{"foo", "4 / 2 equals $ADDRESS / 2 $BAR"}};
186 auto it = j.begin();
Andrew Jeffery1983d2f2022-04-05 14:55:13 +0930187 DBusInterface data;
Zhikui Rena0d1b3f2021-10-05 16:21:56 -0700188 data["ADDRESS"] = 4;
189 data["BAR"] = std::string("bar");
190
Christopher Meis59ef1e72025-04-16 08:53:25 +0200191 em_utils::templateCharReplace(it, data, 0);
Zhikui Rena0d1b3f2021-10-05 16:21:56 -0700192
193 nlohmann::json expected = "4 / 2 equals 2 bar";
James Feist8c20feb2019-08-14 15:10:11 -0700194 EXPECT_EQ(expected, j["foo"]);
James Feistb0097d42019-08-15 09:24:13 -0700195}
196
197TEST(TemplateCharReplace, hexAndWrongCase)
198{
199 nlohmann::json j = {{"Address", "0x54"},
200 {"Bus", 15},
201 {"Name", "$bus sensor 0"},
202 {"Type", "SomeType"}};
203
Andrew Jeffery1983d2f2022-04-05 14:55:13 +0930204 DBusInterface data;
James Feistb0097d42019-08-15 09:24:13 -0700205 data["BUS"] = 15;
206
207 for (auto it = j.begin(); it != j.end(); it++)
208 {
Christopher Meis59ef1e72025-04-16 08:53:25 +0200209 em_utils::templateCharReplace(it, data, 0);
James Feistb0097d42019-08-15 09:24:13 -0700210 }
211 nlohmann::json expected = {{"Address", 84},
212 {"Bus", 15},
213 {"Name", "15 sensor 0"},
214 {"Type", "SomeType"}};
215 EXPECT_EQ(expected, j);
216}
217
218TEST(TemplateCharReplace, replaceSecondAsInt)
219{
220 nlohmann::json j = {{"foo", "twelve is $TEST"}};
221 auto it = j.begin();
Andrew Jeffery1983d2f2022-04-05 14:55:13 +0930222 DBusInterface data;
James Feistb0097d42019-08-15 09:24:13 -0700223 data["test"] = 12;
224
Christopher Meis59ef1e72025-04-16 08:53:25 +0200225 em_utils::templateCharReplace(it, data, 0);
James Feistb0097d42019-08-15 09:24:13 -0700226
227 nlohmann::json expected = "twelve is 12";
228 EXPECT_EQ(expected, j["foo"]);
229}
James Feistc296c802019-08-28 09:26:47 -0700230
231TEST(TemplateCharReplace, singleHex)
232{
233 nlohmann::json j = {{"foo", "0x54"}};
234 auto it = j.begin();
Andrew Jeffery1983d2f2022-04-05 14:55:13 +0930235 DBusInterface data;
James Feistc296c802019-08-28 09:26:47 -0700236
Christopher Meis59ef1e72025-04-16 08:53:25 +0200237 em_utils::templateCharReplace(it, data, 0);
James Feistc296c802019-08-28 09:26:47 -0700238
239 nlohmann::json expected = 84;
240 EXPECT_EQ(expected, j["foo"]);
241}
Brad Bishop9d2ef082020-08-26 15:17:55 -0400242
243TEST(MatchProbe, stringEqString)
244{
245 nlohmann::json j = R"("foo")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930246 DBusValueVariant v = "foo"s;
Brad Bishop9d2ef082020-08-26 15:17:55 -0400247 EXPECT_TRUE(matchProbe(j, v));
248}
249
250TEST(MatchProbe, stringRegexEqString)
251{
252 nlohmann::json j = R"("foo*")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930253 DBusValueVariant v = "foobar"s;
Brad Bishop9d2ef082020-08-26 15:17:55 -0400254 EXPECT_TRUE(matchProbe(j, v));
255}
256
257TEST(MatchProbe, stringNeqString)
258{
259 nlohmann::json j = R"("foobar")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930260 DBusValueVariant v = "foo"s;
Brad Bishop9d2ef082020-08-26 15:17:55 -0400261 EXPECT_FALSE(matchProbe(j, v));
262}
263
264TEST(MatchProbe, stringRegexError)
265{
266 nlohmann::json j = R"("foo[")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930267 DBusValueVariant v = "foobar"s;
Brad Bishop5d525412020-08-26 08:50:50 -0400268 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop9d2ef082020-08-26 15:17:55 -0400269}
270
Patrick Rudolph1c39d7b2023-09-21 15:50:20 +0200271TEST(MatchProbe, stringRegexNotPrefix)
272{
273 nlohmann::json j = R"("foo(?!bar)...foo")"_json;
274 DBusValueVariant v1 = "foobarfoo"s;
275 DBusValueVariant v2 = "foofoofoo"s;
276 EXPECT_FALSE(matchProbe(j, v1));
277 EXPECT_TRUE(matchProbe(j, v2));
278}
279
Brad Bishop5d525412020-08-26 08:50:50 -0400280TEST(MatchProbe, stringZeroNeqFalse)
Brad Bishop9d2ef082020-08-26 15:17:55 -0400281{
282 nlohmann::json j = R"("0")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930283 DBusValueVariant v = false;
Brad Bishop5d525412020-08-26 08:50:50 -0400284 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop9d2ef082020-08-26 15:17:55 -0400285}
286
Brad Bishop5d525412020-08-26 08:50:50 -0400287TEST(MatchProbe, stringOneNeqTrue)
Brad Bishop9d2ef082020-08-26 15:17:55 -0400288{
289 nlohmann::json j = R"("1")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930290 DBusValueVariant v = true;
Brad Bishop5d525412020-08-26 08:50:50 -0400291 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop9d2ef082020-08-26 15:17:55 -0400292}
293
294TEST(MatchProbe, stringElevenNeqTrue)
295{
296 nlohmann::json j = R"("11")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930297 DBusValueVariant v = true;
Brad Bishop9d2ef082020-08-26 15:17:55 -0400298 EXPECT_FALSE(matchProbe(j, v));
299}
300
301TEST(MatchProbe, stringFalseNeqFalse)
302{
303 nlohmann::json j = R"("false")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930304 DBusValueVariant v = false;
Brad Bishop9d2ef082020-08-26 15:17:55 -0400305 EXPECT_FALSE(matchProbe(j, v));
306}
307
308TEST(MatchProbe, stringTrueNeqTrue)
309{
310 nlohmann::json j = R"("true")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930311 DBusValueVariant v = true;
Brad Bishop9d2ef082020-08-26 15:17:55 -0400312 EXPECT_FALSE(matchProbe(j, v));
313}
314
315TEST(MatchProbe, stringFalseNeqTrue)
316{
317 nlohmann::json j = R"("false")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930318 DBusValueVariant v = true;
Brad Bishop9d2ef082020-08-26 15:17:55 -0400319 EXPECT_FALSE(matchProbe(j, v));
320}
321
Brad Bishop5d525412020-08-26 08:50:50 -0400322TEST(MatchProbe, stringNeqUint8)
Brad Bishop9d2ef082020-08-26 15:17:55 -0400323{
324 nlohmann::json j = R"("255")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930325 DBusValueVariant v = uint8_t(255);
Brad Bishop5d525412020-08-26 08:50:50 -0400326 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop9d2ef082020-08-26 15:17:55 -0400327}
328
329TEST(MatchProbe, stringNeqUint8Overflow)
330{
331 nlohmann::json j = R"("65535")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930332 DBusValueVariant v = uint8_t(255);
Brad Bishop9d2ef082020-08-26 15:17:55 -0400333 EXPECT_FALSE(matchProbe(j, v));
334}
335
336TEST(MatchProbe, stringFalseNeqUint8Zero)
337{
338 nlohmann::json j = R"("false")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930339 DBusValueVariant v = uint8_t(0);
Brad Bishop9d2ef082020-08-26 15:17:55 -0400340 EXPECT_FALSE(matchProbe(j, v));
341}
342
343TEST(MatchProbe, stringTrueNeqUint8Zero)
344{
345 nlohmann::json j = R"("true")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930346 DBusValueVariant v = uint8_t(1);
Brad Bishop9d2ef082020-08-26 15:17:55 -0400347 EXPECT_FALSE(matchProbe(j, v));
348}
349
Brad Bishop5d525412020-08-26 08:50:50 -0400350TEST(MatchProbe, stringNeqUint32)
Brad Bishop9d2ef082020-08-26 15:17:55 -0400351{
352 nlohmann::json j = R"("11")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930353 DBusValueVariant v = uint32_t(11);
Brad Bishop9d2ef082020-08-26 15:17:55 -0400354 EXPECT_FALSE(matchProbe(j, v));
355}
356
Brad Bishop9d2ef082020-08-26 15:17:55 -0400357TEST(MatchProbe, stringNeqInt32)
358{
Brad Bishop5d525412020-08-26 08:50:50 -0400359 nlohmann::json j = R"("-11")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930360 DBusValueVariant v = int32_t(-11);
Brad Bishop9d2ef082020-08-26 15:17:55 -0400361 EXPECT_FALSE(matchProbe(j, v));
362}
363
Brad Bishop5d525412020-08-26 08:50:50 -0400364TEST(MatchProbe, stringRegexNeqInt32)
Brad Bishop9d2ef082020-08-26 15:17:55 -0400365{
366 nlohmann::json j = R"("1*4")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930367 DBusValueVariant v = int32_t(124);
Brad Bishop5d525412020-08-26 08:50:50 -0400368 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop9d2ef082020-08-26 15:17:55 -0400369}
370
371TEST(MatchProbe, stringNeqUint64)
372{
373 nlohmann::json j = R"("foo")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930374 DBusValueVariant v = uint64_t(65535);
Brad Bishop9d2ef082020-08-26 15:17:55 -0400375 EXPECT_FALSE(matchProbe(j, v));
376}
377
Brad Bishop9d2ef082020-08-26 15:17:55 -0400378TEST(MatchProbe, stringNeqDouble)
379{
Brad Bishop5d525412020-08-26 08:50:50 -0400380 nlohmann::json j = R"("123.4")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930381 DBusValueVariant v = double(123.4);
Brad Bishop9d2ef082020-08-26 15:17:55 -0400382 EXPECT_FALSE(matchProbe(j, v));
383}
384
385TEST(MatchProbe, stringNeqEmpty)
386{
387 nlohmann::json j = R"("-123.4")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930388 DBusValueVariant v;
Brad Bishop9d2ef082020-08-26 15:17:55 -0400389 EXPECT_FALSE(matchProbe(j, v));
390}
Brad Bishopc5eba592020-08-28 10:38:24 -0400391
Brad Bishopcd1868e2020-08-28 17:58:52 -0400392TEST(MatchProbe, stringNeqArray)
393{
394 nlohmann::json j = R"("-123.4")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930395 DBusValueVariant v = std::vector<uint8_t>{1, 2};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400396 EXPECT_FALSE(matchProbe(j, v));
397}
398
Brad Bishop5d525412020-08-26 08:50:50 -0400399TEST(MatchProbe, boolNeqString)
Brad Bishopc5eba592020-08-28 10:38:24 -0400400{
401 nlohmann::json j = R"(false)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930402 DBusValueVariant v = "false"s;
Brad Bishop5d525412020-08-26 08:50:50 -0400403 EXPECT_FALSE(matchProbe(j, v));
Brad Bishopc5eba592020-08-28 10:38:24 -0400404}
405
406TEST(MatchProbe, trueEqTrue)
407{
408 nlohmann::json j = R"(true)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930409 DBusValueVariant v = true;
Brad Bishopc5eba592020-08-28 10:38:24 -0400410 EXPECT_TRUE(matchProbe(j, v));
411}
412
413TEST(MatchProbe, falseEqFalse)
414{
415 nlohmann::json j = R"(false)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930416 DBusValueVariant v = false;
Brad Bishopc5eba592020-08-28 10:38:24 -0400417 EXPECT_TRUE(matchProbe(j, v));
418}
419
420TEST(MatchProbe, trueNeqFalse)
421{
422 nlohmann::json j = R"(true)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930423 DBusValueVariant v = false;
Brad Bishopc5eba592020-08-28 10:38:24 -0400424 EXPECT_FALSE(matchProbe(j, v));
425}
426
427TEST(MatchProbe, trueNeqInt32Zero)
428{
429 nlohmann::json j = R"(true)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930430 DBusValueVariant v = int32_t(0);
Brad Bishopc5eba592020-08-28 10:38:24 -0400431 EXPECT_FALSE(matchProbe(j, v));
432}
433
434TEST(MatchProbe, trueNeqInt32NegativeOne)
435{
436 nlohmann::json j = R"(true)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930437 DBusValueVariant v = int32_t(-1);
Brad Bishopc5eba592020-08-28 10:38:24 -0400438 EXPECT_FALSE(matchProbe(j, v));
439}
440
441TEST(MatchProbe, falseNeqUint32One)
442{
443 nlohmann::json j = R"(false)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930444 DBusValueVariant v = uint32_t(1);
Brad Bishopc5eba592020-08-28 10:38:24 -0400445 EXPECT_FALSE(matchProbe(j, v));
446}
447
Brad Bishop5d525412020-08-26 08:50:50 -0400448TEST(MatchProbe, falseNeqUint32Zero)
Brad Bishopc5eba592020-08-28 10:38:24 -0400449{
450 nlohmann::json j = R"(false)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930451 DBusValueVariant v = uint32_t(0);
Brad Bishop5d525412020-08-26 08:50:50 -0400452 EXPECT_FALSE(matchProbe(j, v));
Brad Bishopc5eba592020-08-28 10:38:24 -0400453}
454
455TEST(MatchProbe, trueNeqDoubleNegativeOne)
456{
457 nlohmann::json j = R"(true)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930458 DBusValueVariant v = double(-1.1);
Brad Bishopc5eba592020-08-28 10:38:24 -0400459 EXPECT_FALSE(matchProbe(j, v));
460}
461
Brad Bishop5d525412020-08-26 08:50:50 -0400462TEST(MatchProbe, trueNeqDoubleOne)
Brad Bishopc5eba592020-08-28 10:38:24 -0400463{
464 nlohmann::json j = R"(true)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930465 DBusValueVariant v = double(1.0);
Brad Bishop5d525412020-08-26 08:50:50 -0400466 EXPECT_FALSE(matchProbe(j, v));
Brad Bishopc5eba592020-08-28 10:38:24 -0400467}
468
469TEST(MatchProbe, falseNeqDoubleOne)
470{
471 nlohmann::json j = R"(false)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930472 DBusValueVariant v = double(1.0);
Brad Bishopc5eba592020-08-28 10:38:24 -0400473 EXPECT_FALSE(matchProbe(j, v));
474}
475
Brad Bishop5d525412020-08-26 08:50:50 -0400476TEST(MatchProbe, falseNeqDoubleZero)
Brad Bishopc5eba592020-08-28 10:38:24 -0400477{
478 nlohmann::json j = R"(false)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930479 DBusValueVariant v = double(0.0);
Brad Bishop5d525412020-08-26 08:50:50 -0400480 EXPECT_FALSE(matchProbe(j, v));
Brad Bishopc5eba592020-08-28 10:38:24 -0400481}
482
Brad Bishop5d525412020-08-26 08:50:50 -0400483TEST(MatchProbe, falseNeqEmpty)
Brad Bishopc5eba592020-08-28 10:38:24 -0400484{
485 nlohmann::json j = R"(false)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930486 DBusValueVariant v;
Brad Bishop5d525412020-08-26 08:50:50 -0400487 EXPECT_FALSE(matchProbe(j, v));
Brad Bishopc5eba592020-08-28 10:38:24 -0400488}
489
Brad Bishop5d525412020-08-26 08:50:50 -0400490TEST(MatchProbe, trueNeqEmpty)
Brad Bishopc5eba592020-08-28 10:38:24 -0400491{
492 nlohmann::json j = R"(true)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930493 DBusValueVariant v;
Brad Bishop5d525412020-08-26 08:50:50 -0400494 EXPECT_FALSE(matchProbe(j, v));
Brad Bishopc5eba592020-08-28 10:38:24 -0400495}
Brad Bishopc2af5312020-08-28 10:39:49 -0400496
Brad Bishopcd1868e2020-08-28 17:58:52 -0400497TEST(MatchProbe, trueNeqArray)
498{
499 nlohmann::json j = R"(true)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930500 DBusValueVariant v = std::vector<uint8_t>{1, 2};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400501 EXPECT_FALSE(matchProbe(j, v));
502}
503
Brad Bishop5d525412020-08-26 08:50:50 -0400504TEST(MatchProbe, uintNeqString)
Brad Bishopc2af5312020-08-28 10:39:49 -0400505{
506 nlohmann::json j = R"(11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930507 DBusValueVariant v = "11"s;
Brad Bishop5d525412020-08-26 08:50:50 -0400508 EXPECT_FALSE(matchProbe(j, v));
Brad Bishopc2af5312020-08-28 10:39:49 -0400509}
510
511TEST(MatchProbe, uintNeqTrue)
512{
Brad Bishop5d525412020-08-26 08:50:50 -0400513 nlohmann::json j = R"(1)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930514 DBusValueVariant v = true;
Brad Bishopc2af5312020-08-28 10:39:49 -0400515 EXPECT_FALSE(matchProbe(j, v));
516}
517
Brad Bishop5d525412020-08-26 08:50:50 -0400518TEST(MatchProbe, uintNeqFalse)
519{
520 nlohmann::json j = R"(0)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930521 DBusValueVariant v = false;
Brad Bishop5d525412020-08-26 08:50:50 -0400522 EXPECT_FALSE(matchProbe(j, v));
523}
524
Brad Bishopc2af5312020-08-28 10:39:49 -0400525TEST(MatchProbe, uintEqUint8)
526{
527 nlohmann::json j = R"(11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930528 DBusValueVariant v = uint8_t(11);
Brad Bishopc2af5312020-08-28 10:39:49 -0400529 EXPECT_TRUE(matchProbe(j, v));
530}
531
532TEST(MatchProbe, uintNeqUint8)
533{
534 nlohmann::json j = R"(11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930535 DBusValueVariant v = uint8_t(12);
Brad Bishopc2af5312020-08-28 10:39:49 -0400536 EXPECT_FALSE(matchProbe(j, v));
537}
538
539TEST(MatchProbe, uintNeqUint8Overflow)
540{
541 nlohmann::json j = R"(65535)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930542 DBusValueVariant v = uint8_t(255);
Brad Bishopc2af5312020-08-28 10:39:49 -0400543 EXPECT_FALSE(matchProbe(j, v));
544}
545
546TEST(MatchProbe, uintEqInt8)
547{
548 nlohmann::json j = R"(11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930549 DBusValueVariant v = int8_t(11);
Brad Bishopc2af5312020-08-28 10:39:49 -0400550 EXPECT_TRUE(matchProbe(j, v));
551}
552
553TEST(MatchProbe, uintEqDouble)
554{
555 nlohmann::json j = R"(11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930556 DBusValueVariant v = double(11.0);
Brad Bishopc2af5312020-08-28 10:39:49 -0400557 EXPECT_TRUE(matchProbe(j, v));
558}
559
Brad Bishop5d525412020-08-26 08:50:50 -0400560TEST(MatchProbe, uintNeqDouble)
Brad Bishopc2af5312020-08-28 10:39:49 -0400561{
562 nlohmann::json j = R"(11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930563 DBusValueVariant v = double(11.7);
Brad Bishop5d525412020-08-26 08:50:50 -0400564 EXPECT_FALSE(matchProbe(j, v));
Brad Bishopc2af5312020-08-28 10:39:49 -0400565}
566
Brad Bishop5d525412020-08-26 08:50:50 -0400567TEST(MatchProbe, uintNeqEmpty)
Brad Bishopc2af5312020-08-28 10:39:49 -0400568{
569 nlohmann::json j = R"(11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930570 DBusValueVariant v;
Brad Bishop5d525412020-08-26 08:50:50 -0400571 EXPECT_FALSE(matchProbe(j, v));
Brad Bishopc2af5312020-08-28 10:39:49 -0400572}
Brad Bishop667e0502020-08-28 10:41:40 -0400573
Brad Bishopcd1868e2020-08-28 17:58:52 -0400574TEST(MatchProbe, uintNeqArray)
575{
576 nlohmann::json j = R"(11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930577 DBusValueVariant v = std::vector<uint8_t>{11};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400578 EXPECT_FALSE(matchProbe(j, v));
579}
580
Brad Bishop5d525412020-08-26 08:50:50 -0400581TEST(MatchProbe, intNeqString)
Brad Bishop667e0502020-08-28 10:41:40 -0400582{
583 nlohmann::json j = R"(-11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930584 DBusValueVariant v = "-11"s;
Brad Bishop5d525412020-08-26 08:50:50 -0400585 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop667e0502020-08-28 10:41:40 -0400586}
587
588TEST(MatchProbe, intNeqTrue)
589{
590 nlohmann::json j = R"(-1)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930591 DBusValueVariant v = true;
Brad Bishop667e0502020-08-28 10:41:40 -0400592 EXPECT_FALSE(matchProbe(j, v));
593}
594
595TEST(MatchProbe, intNeqUint8)
596{
597 nlohmann::json j = R"(-11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930598 DBusValueVariant v = uint8_t(11);
Brad Bishop667e0502020-08-28 10:41:40 -0400599 EXPECT_FALSE(matchProbe(j, v));
600}
601
602TEST(MatchProbe, intEqInt8)
603{
604 nlohmann::json j = R"(-11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930605 DBusValueVariant v = int8_t(-11);
Brad Bishop667e0502020-08-28 10:41:40 -0400606 EXPECT_TRUE(matchProbe(j, v));
607}
608
609TEST(MatchProbe, intNeqDouble)
610{
611 nlohmann::json j = R"(-124)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930612 DBusValueVariant v = double(-123.0);
Brad Bishop667e0502020-08-28 10:41:40 -0400613 EXPECT_FALSE(matchProbe(j, v));
614}
615
616TEST(MatchProbe, intEqDouble)
617{
618 nlohmann::json j = R"(-11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930619 DBusValueVariant v = double(-11.0);
Brad Bishop667e0502020-08-28 10:41:40 -0400620 EXPECT_TRUE(matchProbe(j, v));
621}
622
Brad Bishop5d525412020-08-26 08:50:50 -0400623TEST(MatchProbe, intNeqDoubleRound)
Brad Bishop667e0502020-08-28 10:41:40 -0400624{
625 nlohmann::json j = R"(-11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930626 DBusValueVariant v = double(-11.7);
Brad Bishop5d525412020-08-26 08:50:50 -0400627 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop667e0502020-08-28 10:41:40 -0400628}
629
Brad Bishop5d525412020-08-26 08:50:50 -0400630TEST(MatchProbe, intNeqEmpty)
Brad Bishop667e0502020-08-28 10:41:40 -0400631{
632 nlohmann::json j = R"(-11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930633 DBusValueVariant v;
Brad Bishop5d525412020-08-26 08:50:50 -0400634 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop667e0502020-08-28 10:41:40 -0400635}
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400636
Brad Bishopcd1868e2020-08-28 17:58:52 -0400637TEST(MatchProbe, intNeqArray)
638{
639 nlohmann::json j = R"(-11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930640 DBusValueVariant v = std::vector<uint8_t>{11};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400641 EXPECT_FALSE(matchProbe(j, v));
642}
643
Brad Bishop5d525412020-08-26 08:50:50 -0400644TEST(MatchProbe, doubleNeqString)
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400645{
646 nlohmann::json j = R"(0.0)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930647 DBusValueVariant v = "0.0"s;
Brad Bishop5d525412020-08-26 08:50:50 -0400648 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400649}
650
Brad Bishop5d525412020-08-26 08:50:50 -0400651TEST(MatchProbe, doubleNeqFalse)
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400652{
653 nlohmann::json j = R"(0.0)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930654 DBusValueVariant v = false;
Brad Bishop5d525412020-08-26 08:50:50 -0400655 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400656}
657
658TEST(MatchProbe, doubleNeqTrue)
659{
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400660 nlohmann::json j = R"(1.0)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930661 DBusValueVariant v = true;
Brad Bishop5d525412020-08-26 08:50:50 -0400662 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400663}
664
665TEST(MatchProbe, doubleEqInt32)
666{
667 nlohmann::json j = R"(-124.0)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930668 DBusValueVariant v = int32_t(-124);
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400669 EXPECT_TRUE(matchProbe(j, v));
670}
671
672TEST(MatchProbe, doubleNeqInt32)
673{
674 nlohmann::json j = R"(-124.0)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930675 DBusValueVariant v = int32_t(-123);
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400676 EXPECT_FALSE(matchProbe(j, v));
677}
678
679TEST(MatchProbe, doubleRoundNeqInt)
680{
681 nlohmann::json j = R"(124.7)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930682 DBusValueVariant v = int32_t(124);
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400683 EXPECT_FALSE(matchProbe(j, v));
684}
685TEST(MatchProbe, doubleEqDouble)
686{
687 nlohmann::json j = R"(-124.2)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930688 DBusValueVariant v = double(-124.2);
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400689 EXPECT_TRUE(matchProbe(j, v));
690}
691
692TEST(MatchProbe, doubleNeqDouble)
693{
694 nlohmann::json j = R"(-124.3)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930695 DBusValueVariant v = double(-124.2);
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400696 EXPECT_FALSE(matchProbe(j, v));
697}
698
Brad Bishop5d525412020-08-26 08:50:50 -0400699TEST(MatchProbe, doubleNeqEmpty)
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400700{
701 nlohmann::json j = R"(-11.0)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930702 DBusValueVariant v;
Brad Bishop5d525412020-08-26 08:50:50 -0400703 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400704}
Brad Bishopd14c2e22020-08-28 10:43:40 -0400705
Brad Bishopcd1868e2020-08-28 17:58:52 -0400706TEST(MatchProbe, doubleNeqArray)
707{
708 nlohmann::json j = R"(-11.2)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930709 DBusValueVariant v = std::vector<uint8_t>{11};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400710 EXPECT_FALSE(matchProbe(j, v));
711}
712
Brad Bishopd14c2e22020-08-28 10:43:40 -0400713TEST(MatchProbe, arrayNeqString)
714{
715 nlohmann::json j = R"([1, 2])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930716 DBusValueVariant v = "hello"s;
Brad Bishopd14c2e22020-08-28 10:43:40 -0400717 EXPECT_FALSE(matchProbe(j, v));
718}
719
720TEST(MatchProbe, arrayNeqFalse)
721{
722 nlohmann::json j = R"([1, 2])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930723 DBusValueVariant v = false;
Brad Bishopd14c2e22020-08-28 10:43:40 -0400724 EXPECT_FALSE(matchProbe(j, v));
725}
726
727TEST(MatchProbe, arrayNeqTrue)
728{
729 nlohmann::json j = R"([1, 2])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930730 DBusValueVariant v = true;
Brad Bishopd14c2e22020-08-28 10:43:40 -0400731 EXPECT_FALSE(matchProbe(j, v));
732}
733
734TEST(MatchProbe, arrayNeqUint8)
735{
736 nlohmann::json j = R"([1, 2])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930737 DBusValueVariant v = uint8_t(1);
Brad Bishopd14c2e22020-08-28 10:43:40 -0400738 EXPECT_FALSE(matchProbe(j, v));
739}
740
741TEST(MatchProbe, arrayNeqInt32)
742{
743 nlohmann::json j = R"([1, 2])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930744 DBusValueVariant v = int32_t(-1);
Brad Bishopd14c2e22020-08-28 10:43:40 -0400745 EXPECT_FALSE(matchProbe(j, v));
746}
747
748TEST(MatchProbe, arrayNeqDouble)
749{
750 nlohmann::json j = R"([1, 2])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930751 DBusValueVariant v = double(1.1);
Brad Bishopd14c2e22020-08-28 10:43:40 -0400752 EXPECT_FALSE(matchProbe(j, v));
753}
Brad Bishop6660e2a2020-08-28 10:44:41 -0400754
Brad Bishopcd1868e2020-08-28 17:58:52 -0400755TEST(MatchProbe, arrayEqArray)
756{
757 nlohmann::json j = R"([1, 2])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930758 DBusValueVariant v = std::vector<uint8_t>{1, 2};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400759 EXPECT_TRUE(matchProbe(j, v));
760}
761
762TEST(MatchProbe, arrayNeqArrayDiffSize1)
763{
764 nlohmann::json j = R"([1, 2, 3])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930765 DBusValueVariant v = std::vector<uint8_t>{1, 2};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400766 EXPECT_FALSE(matchProbe(j, v));
767}
768
769TEST(MatchProbe, arrayNeqArrayDiffSize2)
770{
771 nlohmann::json j = R"([1, 2])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930772 DBusValueVariant v = std::vector<uint8_t>{1, 2, 3};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400773 EXPECT_FALSE(matchProbe(j, v));
774}
775
776TEST(MatchProbe, emptyArrayEqEmptyArray)
777{
778 nlohmann::json j = R"([])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930779 DBusValueVariant v = std::vector<uint8_t>{};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400780 EXPECT_TRUE(matchProbe(j, v));
781}
782
783TEST(MatchProbe, emptyArrayNeqArray)
784{
785 nlohmann::json j = R"([])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930786 DBusValueVariant v = std::vector<uint8_t>{1};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400787 EXPECT_FALSE(matchProbe(j, v));
788}
789
790TEST(MatchProbe, arrayNeqEmptyArray)
791{
792 nlohmann::json j = R"([1])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930793 DBusValueVariant v = std::vector<uint8_t>{};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400794 EXPECT_FALSE(matchProbe(j, v));
795}
796
Brad Bishop6660e2a2020-08-28 10:44:41 -0400797TEST(MatchProbe, objNeqString)
798{
799 nlohmann::json j = R"({"foo": "bar"})"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930800 DBusValueVariant v = "hello"s;
Brad Bishop6660e2a2020-08-28 10:44:41 -0400801 EXPECT_FALSE(matchProbe(j, v));
802}
803
804TEST(MatchProbe, objNeqFalse)
805{
806 nlohmann::json j = R"({"foo": "bar"})"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930807 DBusValueVariant v = false;
Brad Bishop6660e2a2020-08-28 10:44:41 -0400808 EXPECT_FALSE(matchProbe(j, v));
809}
810
811TEST(MatchProbe, objNeqTrue)
812{
813 nlohmann::json j = R"({"foo": "bar"})"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930814 DBusValueVariant v = true;
Brad Bishop6660e2a2020-08-28 10:44:41 -0400815 EXPECT_FALSE(matchProbe(j, v));
816}
817
818TEST(MatchProbe, objNeqUint8)
819{
820 nlohmann::json j = R"({"foo": "bar"})"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930821 DBusValueVariant v = uint8_t(1);
Brad Bishop6660e2a2020-08-28 10:44:41 -0400822 EXPECT_FALSE(matchProbe(j, v));
823}
824
825TEST(MatchProbe, objNeqInt32)
826{
827 nlohmann::json j = R"({"foo": "bar"})"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930828 DBusValueVariant v = int32_t(-1);
Brad Bishop6660e2a2020-08-28 10:44:41 -0400829 EXPECT_FALSE(matchProbe(j, v));
830}
831
832TEST(MatchProbe, objNeqDouble)
833{
834 nlohmann::json j = R"({"foo": "bar"})"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930835 DBusValueVariant v = double(1.1);
Brad Bishop6660e2a2020-08-28 10:44:41 -0400836 EXPECT_FALSE(matchProbe(j, v));
837}
Brad Bishopc776c412020-08-28 10:45:25 -0400838
Brad Bishopcd1868e2020-08-28 17:58:52 -0400839TEST(MatchProbe, objNeqArray)
840{
841 nlohmann::json j = R"({"foo": "bar"})"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930842 DBusValueVariant v = std::vector<uint8_t>{1, 2};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400843 EXPECT_FALSE(matchProbe(j, v));
844}
845
Brad Bishopc776c412020-08-28 10:45:25 -0400846TEST(MatchProbe, nullNeqString)
847{
848 nlohmann::json j = R"(null)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930849 DBusValueVariant v = "hello"s;
Brad Bishopc776c412020-08-28 10:45:25 -0400850 EXPECT_FALSE(matchProbe(j, v));
851}
852
853TEST(MatchProbe, nullNeqFalse)
854{
855 nlohmann::json j = R"(null)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930856 DBusValueVariant v = false;
Brad Bishopc776c412020-08-28 10:45:25 -0400857 EXPECT_FALSE(matchProbe(j, v));
858}
859
860TEST(MatchProbe, nullNeqTrue)
861{
862 nlohmann::json j = R"(null)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930863 DBusValueVariant v = true;
Brad Bishopc776c412020-08-28 10:45:25 -0400864 EXPECT_FALSE(matchProbe(j, v));
865}
866
867TEST(MatchProbe, nullNeqUint8)
868{
869 nlohmann::json j = R"(null)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930870 DBusValueVariant v = uint8_t(1);
Brad Bishopc776c412020-08-28 10:45:25 -0400871 EXPECT_FALSE(matchProbe(j, v));
872}
873
874TEST(MatchProbe, nullNeqInt32)
875{
876 nlohmann::json j = R"(null)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930877 DBusValueVariant v = int32_t(-1);
Brad Bishopc776c412020-08-28 10:45:25 -0400878 EXPECT_FALSE(matchProbe(j, v));
879}
880
881TEST(MatchProbe, nullNeqDouble)
882{
883 nlohmann::json j = R"(null)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930884 DBusValueVariant v = double(1.1);
Brad Bishopc776c412020-08-28 10:45:25 -0400885 EXPECT_FALSE(matchProbe(j, v));
886}
Brad Bishopcd1868e2020-08-28 17:58:52 -0400887
888TEST(MatchProbe, nullNeqArray)
889{
890 nlohmann::json j = R"(null)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930891 DBusValueVariant v = std::vector<uint8_t>{};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400892 EXPECT_FALSE(matchProbe(j, v));
893}