blob: cc59e449d862390f8cb95ca11470fed134bde4be [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
Chau Ly79629442025-08-20 10:27:20 +0000243TEST(TemplateCharReplace, leftOverTemplateVars)
244{
245 nlohmann::json j = {{"foo", "$EXISTENT_VAR and $NON_EXISTENT_VAR"}};
246 auto it = j.begin();
247
248 DBusInterface data;
249 data["EXISTENT_VAR"] = std::string("Replaced");
250
251 DBusObject object;
252 object["PATH"] = data;
253
254 em_utils::templateCharReplace(it, object, 0);
255
256 nlohmann::json expected = "Replaced and ";
257 EXPECT_EQ(expected, j["foo"]);
258}
259
260TEST(HandleLeftOverTemplateVars, replaceLeftOverTemplateVar)
261{
262 nlohmann::json j = {{"foo", "the Test $TEST is $TESTED"}};
263 auto it = j.begin();
264
265 em_utils::handleLeftOverTemplateVars(it);
266
267 nlohmann::json expected = "the Test is ";
268 EXPECT_EQ(expected, j["foo"]);
269}
270
Brad Bishop9d2ef082020-08-26 15:17:55 -0400271TEST(MatchProbe, stringEqString)
272{
273 nlohmann::json j = R"("foo")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930274 DBusValueVariant v = "foo"s;
Brad Bishop9d2ef082020-08-26 15:17:55 -0400275 EXPECT_TRUE(matchProbe(j, v));
276}
277
278TEST(MatchProbe, stringRegexEqString)
279{
280 nlohmann::json j = R"("foo*")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930281 DBusValueVariant v = "foobar"s;
Brad Bishop9d2ef082020-08-26 15:17:55 -0400282 EXPECT_TRUE(matchProbe(j, v));
283}
284
285TEST(MatchProbe, stringNeqString)
286{
287 nlohmann::json j = R"("foobar")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930288 DBusValueVariant v = "foo"s;
Brad Bishop9d2ef082020-08-26 15:17:55 -0400289 EXPECT_FALSE(matchProbe(j, v));
290}
291
292TEST(MatchProbe, stringRegexError)
293{
294 nlohmann::json j = R"("foo[")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930295 DBusValueVariant v = "foobar"s;
Brad Bishop5d525412020-08-26 08:50:50 -0400296 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop9d2ef082020-08-26 15:17:55 -0400297}
298
Patrick Rudolph1c39d7b2023-09-21 15:50:20 +0200299TEST(MatchProbe, stringRegexNotPrefix)
300{
301 nlohmann::json j = R"("foo(?!bar)...foo")"_json;
302 DBusValueVariant v1 = "foobarfoo"s;
303 DBusValueVariant v2 = "foofoofoo"s;
304 EXPECT_FALSE(matchProbe(j, v1));
305 EXPECT_TRUE(matchProbe(j, v2));
306}
307
Brad Bishop5d525412020-08-26 08:50:50 -0400308TEST(MatchProbe, stringZeroNeqFalse)
Brad Bishop9d2ef082020-08-26 15:17:55 -0400309{
310 nlohmann::json j = R"("0")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930311 DBusValueVariant v = false;
Brad Bishop5d525412020-08-26 08:50:50 -0400312 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop9d2ef082020-08-26 15:17:55 -0400313}
314
Brad Bishop5d525412020-08-26 08:50:50 -0400315TEST(MatchProbe, stringOneNeqTrue)
Brad Bishop9d2ef082020-08-26 15:17:55 -0400316{
317 nlohmann::json j = R"("1")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930318 DBusValueVariant v = true;
Brad Bishop5d525412020-08-26 08:50:50 -0400319 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop9d2ef082020-08-26 15:17:55 -0400320}
321
322TEST(MatchProbe, stringElevenNeqTrue)
323{
324 nlohmann::json j = R"("11")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930325 DBusValueVariant v = true;
Brad Bishop9d2ef082020-08-26 15:17:55 -0400326 EXPECT_FALSE(matchProbe(j, v));
327}
328
329TEST(MatchProbe, stringFalseNeqFalse)
330{
331 nlohmann::json j = R"("false")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930332 DBusValueVariant v = false;
Brad Bishop9d2ef082020-08-26 15:17:55 -0400333 EXPECT_FALSE(matchProbe(j, v));
334}
335
336TEST(MatchProbe, stringTrueNeqTrue)
337{
338 nlohmann::json j = R"("true")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930339 DBusValueVariant v = true;
Brad Bishop9d2ef082020-08-26 15:17:55 -0400340 EXPECT_FALSE(matchProbe(j, v));
341}
342
343TEST(MatchProbe, stringFalseNeqTrue)
344{
345 nlohmann::json j = R"("false")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930346 DBusValueVariant v = true;
Brad Bishop9d2ef082020-08-26 15:17:55 -0400347 EXPECT_FALSE(matchProbe(j, v));
348}
349
Brad Bishop5d525412020-08-26 08:50:50 -0400350TEST(MatchProbe, stringNeqUint8)
Brad Bishop9d2ef082020-08-26 15:17:55 -0400351{
352 nlohmann::json j = R"("255")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930353 DBusValueVariant v = uint8_t(255);
Brad Bishop5d525412020-08-26 08:50:50 -0400354 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop9d2ef082020-08-26 15:17:55 -0400355}
356
357TEST(MatchProbe, stringNeqUint8Overflow)
358{
359 nlohmann::json j = R"("65535")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930360 DBusValueVariant v = uint8_t(255);
Brad Bishop9d2ef082020-08-26 15:17:55 -0400361 EXPECT_FALSE(matchProbe(j, v));
362}
363
364TEST(MatchProbe, stringFalseNeqUint8Zero)
365{
366 nlohmann::json j = R"("false")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930367 DBusValueVariant v = uint8_t(0);
Brad Bishop9d2ef082020-08-26 15:17:55 -0400368 EXPECT_FALSE(matchProbe(j, v));
369}
370
371TEST(MatchProbe, stringTrueNeqUint8Zero)
372{
373 nlohmann::json j = R"("true")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930374 DBusValueVariant v = uint8_t(1);
Brad Bishop9d2ef082020-08-26 15:17:55 -0400375 EXPECT_FALSE(matchProbe(j, v));
376}
377
Brad Bishop5d525412020-08-26 08:50:50 -0400378TEST(MatchProbe, stringNeqUint32)
Brad Bishop9d2ef082020-08-26 15:17:55 -0400379{
380 nlohmann::json j = R"("11")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930381 DBusValueVariant v = uint32_t(11);
Brad Bishop9d2ef082020-08-26 15:17:55 -0400382 EXPECT_FALSE(matchProbe(j, v));
383}
384
Brad Bishop9d2ef082020-08-26 15:17:55 -0400385TEST(MatchProbe, stringNeqInt32)
386{
Brad Bishop5d525412020-08-26 08:50:50 -0400387 nlohmann::json j = R"("-11")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930388 DBusValueVariant v = int32_t(-11);
Brad Bishop9d2ef082020-08-26 15:17:55 -0400389 EXPECT_FALSE(matchProbe(j, v));
390}
391
Brad Bishop5d525412020-08-26 08:50:50 -0400392TEST(MatchProbe, stringRegexNeqInt32)
Brad Bishop9d2ef082020-08-26 15:17:55 -0400393{
394 nlohmann::json j = R"("1*4")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930395 DBusValueVariant v = int32_t(124);
Brad Bishop5d525412020-08-26 08:50:50 -0400396 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop9d2ef082020-08-26 15:17:55 -0400397}
398
399TEST(MatchProbe, stringNeqUint64)
400{
401 nlohmann::json j = R"("foo")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930402 DBusValueVariant v = uint64_t(65535);
Brad Bishop9d2ef082020-08-26 15:17:55 -0400403 EXPECT_FALSE(matchProbe(j, v));
404}
405
Brad Bishop9d2ef082020-08-26 15:17:55 -0400406TEST(MatchProbe, stringNeqDouble)
407{
Brad Bishop5d525412020-08-26 08:50:50 -0400408 nlohmann::json j = R"("123.4")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930409 DBusValueVariant v = double(123.4);
Brad Bishop9d2ef082020-08-26 15:17:55 -0400410 EXPECT_FALSE(matchProbe(j, v));
411}
412
413TEST(MatchProbe, stringNeqEmpty)
414{
415 nlohmann::json j = R"("-123.4")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930416 DBusValueVariant v;
Brad Bishop9d2ef082020-08-26 15:17:55 -0400417 EXPECT_FALSE(matchProbe(j, v));
418}
Brad Bishopc5eba592020-08-28 10:38:24 -0400419
Brad Bishopcd1868e2020-08-28 17:58:52 -0400420TEST(MatchProbe, stringNeqArray)
421{
422 nlohmann::json j = R"("-123.4")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930423 DBusValueVariant v = std::vector<uint8_t>{1, 2};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400424 EXPECT_FALSE(matchProbe(j, v));
425}
426
Brad Bishop5d525412020-08-26 08:50:50 -0400427TEST(MatchProbe, boolNeqString)
Brad Bishopc5eba592020-08-28 10:38:24 -0400428{
429 nlohmann::json j = R"(false)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930430 DBusValueVariant v = "false"s;
Brad Bishop5d525412020-08-26 08:50:50 -0400431 EXPECT_FALSE(matchProbe(j, v));
Brad Bishopc5eba592020-08-28 10:38:24 -0400432}
433
434TEST(MatchProbe, trueEqTrue)
435{
436 nlohmann::json j = R"(true)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930437 DBusValueVariant v = true;
Brad Bishopc5eba592020-08-28 10:38:24 -0400438 EXPECT_TRUE(matchProbe(j, v));
439}
440
441TEST(MatchProbe, falseEqFalse)
442{
443 nlohmann::json j = R"(false)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930444 DBusValueVariant v = false;
Brad Bishopc5eba592020-08-28 10:38:24 -0400445 EXPECT_TRUE(matchProbe(j, v));
446}
447
448TEST(MatchProbe, trueNeqFalse)
449{
450 nlohmann::json j = R"(true)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930451 DBusValueVariant v = false;
Brad Bishopc5eba592020-08-28 10:38:24 -0400452 EXPECT_FALSE(matchProbe(j, v));
453}
454
455TEST(MatchProbe, trueNeqInt32Zero)
456{
457 nlohmann::json j = R"(true)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930458 DBusValueVariant v = int32_t(0);
Brad Bishopc5eba592020-08-28 10:38:24 -0400459 EXPECT_FALSE(matchProbe(j, v));
460}
461
462TEST(MatchProbe, trueNeqInt32NegativeOne)
463{
464 nlohmann::json j = R"(true)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930465 DBusValueVariant v = int32_t(-1);
Brad Bishopc5eba592020-08-28 10:38:24 -0400466 EXPECT_FALSE(matchProbe(j, v));
467}
468
469TEST(MatchProbe, falseNeqUint32One)
470{
471 nlohmann::json j = R"(false)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930472 DBusValueVariant v = uint32_t(1);
Brad Bishopc5eba592020-08-28 10:38:24 -0400473 EXPECT_FALSE(matchProbe(j, v));
474}
475
Brad Bishop5d525412020-08-26 08:50:50 -0400476TEST(MatchProbe, falseNeqUint32Zero)
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 = uint32_t(0);
Brad Bishop5d525412020-08-26 08:50:50 -0400480 EXPECT_FALSE(matchProbe(j, v));
Brad Bishopc5eba592020-08-28 10:38:24 -0400481}
482
483TEST(MatchProbe, trueNeqDoubleNegativeOne)
484{
485 nlohmann::json j = R"(true)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930486 DBusValueVariant v = double(-1.1);
Brad Bishopc5eba592020-08-28 10:38:24 -0400487 EXPECT_FALSE(matchProbe(j, v));
488}
489
Brad Bishop5d525412020-08-26 08:50:50 -0400490TEST(MatchProbe, trueNeqDoubleOne)
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 = double(1.0);
Brad Bishop5d525412020-08-26 08:50:50 -0400494 EXPECT_FALSE(matchProbe(j, v));
Brad Bishopc5eba592020-08-28 10:38:24 -0400495}
496
497TEST(MatchProbe, falseNeqDoubleOne)
498{
499 nlohmann::json j = R"(false)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930500 DBusValueVariant v = double(1.0);
Brad Bishopc5eba592020-08-28 10:38:24 -0400501 EXPECT_FALSE(matchProbe(j, v));
502}
503
Brad Bishop5d525412020-08-26 08:50:50 -0400504TEST(MatchProbe, falseNeqDoubleZero)
Brad Bishopc5eba592020-08-28 10:38:24 -0400505{
506 nlohmann::json j = R"(false)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930507 DBusValueVariant v = double(0.0);
Brad Bishop5d525412020-08-26 08:50:50 -0400508 EXPECT_FALSE(matchProbe(j, v));
Brad Bishopc5eba592020-08-28 10:38:24 -0400509}
510
Brad Bishop5d525412020-08-26 08:50:50 -0400511TEST(MatchProbe, falseNeqEmpty)
Brad Bishopc5eba592020-08-28 10:38:24 -0400512{
513 nlohmann::json j = R"(false)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930514 DBusValueVariant v;
Brad Bishop5d525412020-08-26 08:50:50 -0400515 EXPECT_FALSE(matchProbe(j, v));
Brad Bishopc5eba592020-08-28 10:38:24 -0400516}
517
Brad Bishop5d525412020-08-26 08:50:50 -0400518TEST(MatchProbe, trueNeqEmpty)
Brad Bishopc5eba592020-08-28 10:38:24 -0400519{
520 nlohmann::json j = R"(true)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930521 DBusValueVariant v;
Brad Bishop5d525412020-08-26 08:50:50 -0400522 EXPECT_FALSE(matchProbe(j, v));
Brad Bishopc5eba592020-08-28 10:38:24 -0400523}
Brad Bishopc2af5312020-08-28 10:39:49 -0400524
Brad Bishopcd1868e2020-08-28 17:58:52 -0400525TEST(MatchProbe, trueNeqArray)
526{
527 nlohmann::json j = R"(true)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930528 DBusValueVariant v = std::vector<uint8_t>{1, 2};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400529 EXPECT_FALSE(matchProbe(j, v));
530}
531
Brad Bishop5d525412020-08-26 08:50:50 -0400532TEST(MatchProbe, uintNeqString)
Brad Bishopc2af5312020-08-28 10:39:49 -0400533{
534 nlohmann::json j = R"(11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930535 DBusValueVariant v = "11"s;
Brad Bishop5d525412020-08-26 08:50:50 -0400536 EXPECT_FALSE(matchProbe(j, v));
Brad Bishopc2af5312020-08-28 10:39:49 -0400537}
538
539TEST(MatchProbe, uintNeqTrue)
540{
Brad Bishop5d525412020-08-26 08:50:50 -0400541 nlohmann::json j = R"(1)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930542 DBusValueVariant v = true;
Brad Bishopc2af5312020-08-28 10:39:49 -0400543 EXPECT_FALSE(matchProbe(j, v));
544}
545
Brad Bishop5d525412020-08-26 08:50:50 -0400546TEST(MatchProbe, uintNeqFalse)
547{
548 nlohmann::json j = R"(0)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930549 DBusValueVariant v = false;
Brad Bishop5d525412020-08-26 08:50:50 -0400550 EXPECT_FALSE(matchProbe(j, v));
551}
552
Brad Bishopc2af5312020-08-28 10:39:49 -0400553TEST(MatchProbe, uintEqUint8)
554{
555 nlohmann::json j = R"(11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930556 DBusValueVariant v = uint8_t(11);
Brad Bishopc2af5312020-08-28 10:39:49 -0400557 EXPECT_TRUE(matchProbe(j, v));
558}
559
560TEST(MatchProbe, uintNeqUint8)
561{
562 nlohmann::json j = R"(11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930563 DBusValueVariant v = uint8_t(12);
Brad Bishopc2af5312020-08-28 10:39:49 -0400564 EXPECT_FALSE(matchProbe(j, v));
565}
566
567TEST(MatchProbe, uintNeqUint8Overflow)
568{
569 nlohmann::json j = R"(65535)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930570 DBusValueVariant v = uint8_t(255);
Brad Bishopc2af5312020-08-28 10:39:49 -0400571 EXPECT_FALSE(matchProbe(j, v));
572}
573
574TEST(MatchProbe, uintEqInt8)
575{
576 nlohmann::json j = R"(11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930577 DBusValueVariant v = int8_t(11);
Brad Bishopc2af5312020-08-28 10:39:49 -0400578 EXPECT_TRUE(matchProbe(j, v));
579}
580
581TEST(MatchProbe, uintEqDouble)
582{
583 nlohmann::json j = R"(11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930584 DBusValueVariant v = double(11.0);
Brad Bishopc2af5312020-08-28 10:39:49 -0400585 EXPECT_TRUE(matchProbe(j, v));
586}
587
Brad Bishop5d525412020-08-26 08:50:50 -0400588TEST(MatchProbe, uintNeqDouble)
Brad Bishopc2af5312020-08-28 10:39:49 -0400589{
590 nlohmann::json j = R"(11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930591 DBusValueVariant v = double(11.7);
Brad Bishop5d525412020-08-26 08:50:50 -0400592 EXPECT_FALSE(matchProbe(j, v));
Brad Bishopc2af5312020-08-28 10:39:49 -0400593}
594
Brad Bishop5d525412020-08-26 08:50:50 -0400595TEST(MatchProbe, uintNeqEmpty)
Brad Bishopc2af5312020-08-28 10:39:49 -0400596{
597 nlohmann::json j = R"(11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930598 DBusValueVariant v;
Brad Bishop5d525412020-08-26 08:50:50 -0400599 EXPECT_FALSE(matchProbe(j, v));
Brad Bishopc2af5312020-08-28 10:39:49 -0400600}
Brad Bishop667e0502020-08-28 10:41:40 -0400601
Brad Bishopcd1868e2020-08-28 17:58:52 -0400602TEST(MatchProbe, uintNeqArray)
603{
604 nlohmann::json j = R"(11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930605 DBusValueVariant v = std::vector<uint8_t>{11};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400606 EXPECT_FALSE(matchProbe(j, v));
607}
608
Brad Bishop5d525412020-08-26 08:50:50 -0400609TEST(MatchProbe, intNeqString)
Brad Bishop667e0502020-08-28 10:41:40 -0400610{
611 nlohmann::json j = R"(-11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930612 DBusValueVariant v = "-11"s;
Brad Bishop5d525412020-08-26 08:50:50 -0400613 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop667e0502020-08-28 10:41:40 -0400614}
615
616TEST(MatchProbe, intNeqTrue)
617{
618 nlohmann::json j = R"(-1)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930619 DBusValueVariant v = true;
Brad Bishop667e0502020-08-28 10:41:40 -0400620 EXPECT_FALSE(matchProbe(j, v));
621}
622
623TEST(MatchProbe, intNeqUint8)
624{
625 nlohmann::json j = R"(-11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930626 DBusValueVariant v = uint8_t(11);
Brad Bishop667e0502020-08-28 10:41:40 -0400627 EXPECT_FALSE(matchProbe(j, v));
628}
629
630TEST(MatchProbe, intEqInt8)
631{
632 nlohmann::json j = R"(-11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930633 DBusValueVariant v = int8_t(-11);
Brad Bishop667e0502020-08-28 10:41:40 -0400634 EXPECT_TRUE(matchProbe(j, v));
635}
636
637TEST(MatchProbe, intNeqDouble)
638{
639 nlohmann::json j = R"(-124)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930640 DBusValueVariant v = double(-123.0);
Brad Bishop667e0502020-08-28 10:41:40 -0400641 EXPECT_FALSE(matchProbe(j, v));
642}
643
644TEST(MatchProbe, intEqDouble)
645{
646 nlohmann::json j = R"(-11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930647 DBusValueVariant v = double(-11.0);
Brad Bishop667e0502020-08-28 10:41:40 -0400648 EXPECT_TRUE(matchProbe(j, v));
649}
650
Brad Bishop5d525412020-08-26 08:50:50 -0400651TEST(MatchProbe, intNeqDoubleRound)
Brad Bishop667e0502020-08-28 10:41:40 -0400652{
653 nlohmann::json j = R"(-11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930654 DBusValueVariant v = double(-11.7);
Brad Bishop5d525412020-08-26 08:50:50 -0400655 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop667e0502020-08-28 10:41:40 -0400656}
657
Brad Bishop5d525412020-08-26 08:50:50 -0400658TEST(MatchProbe, intNeqEmpty)
Brad Bishop667e0502020-08-28 10:41:40 -0400659{
660 nlohmann::json j = R"(-11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930661 DBusValueVariant v;
Brad Bishop5d525412020-08-26 08:50:50 -0400662 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop667e0502020-08-28 10:41:40 -0400663}
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400664
Brad Bishopcd1868e2020-08-28 17:58:52 -0400665TEST(MatchProbe, intNeqArray)
666{
667 nlohmann::json j = R"(-11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930668 DBusValueVariant v = std::vector<uint8_t>{11};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400669 EXPECT_FALSE(matchProbe(j, v));
670}
671
Brad Bishop5d525412020-08-26 08:50:50 -0400672TEST(MatchProbe, doubleNeqString)
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400673{
674 nlohmann::json j = R"(0.0)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930675 DBusValueVariant v = "0.0"s;
Brad Bishop5d525412020-08-26 08:50:50 -0400676 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400677}
678
Brad Bishop5d525412020-08-26 08:50:50 -0400679TEST(MatchProbe, doubleNeqFalse)
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400680{
681 nlohmann::json j = R"(0.0)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930682 DBusValueVariant v = false;
Brad Bishop5d525412020-08-26 08:50:50 -0400683 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400684}
685
686TEST(MatchProbe, doubleNeqTrue)
687{
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400688 nlohmann::json j = R"(1.0)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930689 DBusValueVariant v = true;
Brad Bishop5d525412020-08-26 08:50:50 -0400690 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400691}
692
693TEST(MatchProbe, doubleEqInt32)
694{
695 nlohmann::json j = R"(-124.0)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930696 DBusValueVariant v = int32_t(-124);
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400697 EXPECT_TRUE(matchProbe(j, v));
698}
699
700TEST(MatchProbe, doubleNeqInt32)
701{
702 nlohmann::json j = R"(-124.0)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930703 DBusValueVariant v = int32_t(-123);
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400704 EXPECT_FALSE(matchProbe(j, v));
705}
706
707TEST(MatchProbe, doubleRoundNeqInt)
708{
709 nlohmann::json j = R"(124.7)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930710 DBusValueVariant v = int32_t(124);
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400711 EXPECT_FALSE(matchProbe(j, v));
712}
713TEST(MatchProbe, doubleEqDouble)
714{
715 nlohmann::json j = R"(-124.2)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930716 DBusValueVariant v = double(-124.2);
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400717 EXPECT_TRUE(matchProbe(j, v));
718}
719
720TEST(MatchProbe, doubleNeqDouble)
721{
722 nlohmann::json j = R"(-124.3)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930723 DBusValueVariant v = double(-124.2);
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400724 EXPECT_FALSE(matchProbe(j, v));
725}
726
Brad Bishop5d525412020-08-26 08:50:50 -0400727TEST(MatchProbe, doubleNeqEmpty)
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400728{
729 nlohmann::json j = R"(-11.0)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930730 DBusValueVariant v;
Brad Bishop5d525412020-08-26 08:50:50 -0400731 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400732}
Brad Bishopd14c2e22020-08-28 10:43:40 -0400733
Brad Bishopcd1868e2020-08-28 17:58:52 -0400734TEST(MatchProbe, doubleNeqArray)
735{
736 nlohmann::json j = R"(-11.2)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930737 DBusValueVariant v = std::vector<uint8_t>{11};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400738 EXPECT_FALSE(matchProbe(j, v));
739}
740
Brad Bishopd14c2e22020-08-28 10:43:40 -0400741TEST(MatchProbe, arrayNeqString)
742{
743 nlohmann::json j = R"([1, 2])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930744 DBusValueVariant v = "hello"s;
Brad Bishopd14c2e22020-08-28 10:43:40 -0400745 EXPECT_FALSE(matchProbe(j, v));
746}
747
748TEST(MatchProbe, arrayNeqFalse)
749{
750 nlohmann::json j = R"([1, 2])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930751 DBusValueVariant v = false;
Brad Bishopd14c2e22020-08-28 10:43:40 -0400752 EXPECT_FALSE(matchProbe(j, v));
753}
754
755TEST(MatchProbe, arrayNeqTrue)
756{
757 nlohmann::json j = R"([1, 2])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930758 DBusValueVariant v = true;
Brad Bishopd14c2e22020-08-28 10:43:40 -0400759 EXPECT_FALSE(matchProbe(j, v));
760}
761
762TEST(MatchProbe, arrayNeqUint8)
763{
764 nlohmann::json j = R"([1, 2])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930765 DBusValueVariant v = uint8_t(1);
Brad Bishopd14c2e22020-08-28 10:43:40 -0400766 EXPECT_FALSE(matchProbe(j, v));
767}
768
769TEST(MatchProbe, arrayNeqInt32)
770{
771 nlohmann::json j = R"([1, 2])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930772 DBusValueVariant v = int32_t(-1);
Brad Bishopd14c2e22020-08-28 10:43:40 -0400773 EXPECT_FALSE(matchProbe(j, v));
774}
775
776TEST(MatchProbe, arrayNeqDouble)
777{
778 nlohmann::json j = R"([1, 2])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930779 DBusValueVariant v = double(1.1);
Brad Bishopd14c2e22020-08-28 10:43:40 -0400780 EXPECT_FALSE(matchProbe(j, v));
781}
Brad Bishop6660e2a2020-08-28 10:44:41 -0400782
Brad Bishopcd1868e2020-08-28 17:58:52 -0400783TEST(MatchProbe, arrayEqArray)
784{
785 nlohmann::json j = R"([1, 2])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930786 DBusValueVariant v = std::vector<uint8_t>{1, 2};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400787 EXPECT_TRUE(matchProbe(j, v));
788}
789
790TEST(MatchProbe, arrayNeqArrayDiffSize1)
791{
792 nlohmann::json j = R"([1, 2, 3])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930793 DBusValueVariant v = std::vector<uint8_t>{1, 2};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400794 EXPECT_FALSE(matchProbe(j, v));
795}
796
797TEST(MatchProbe, arrayNeqArrayDiffSize2)
798{
799 nlohmann::json j = R"([1, 2])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930800 DBusValueVariant v = std::vector<uint8_t>{1, 2, 3};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400801 EXPECT_FALSE(matchProbe(j, v));
802}
803
804TEST(MatchProbe, emptyArrayEqEmptyArray)
805{
806 nlohmann::json j = R"([])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930807 DBusValueVariant v = std::vector<uint8_t>{};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400808 EXPECT_TRUE(matchProbe(j, v));
809}
810
811TEST(MatchProbe, emptyArrayNeqArray)
812{
813 nlohmann::json j = R"([])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930814 DBusValueVariant v = std::vector<uint8_t>{1};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400815 EXPECT_FALSE(matchProbe(j, v));
816}
817
818TEST(MatchProbe, arrayNeqEmptyArray)
819{
820 nlohmann::json j = R"([1])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930821 DBusValueVariant v = std::vector<uint8_t>{};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400822 EXPECT_FALSE(matchProbe(j, v));
823}
824
Brad Bishop6660e2a2020-08-28 10:44:41 -0400825TEST(MatchProbe, objNeqString)
826{
827 nlohmann::json j = R"({"foo": "bar"})"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930828 DBusValueVariant v = "hello"s;
Brad Bishop6660e2a2020-08-28 10:44:41 -0400829 EXPECT_FALSE(matchProbe(j, v));
830}
831
832TEST(MatchProbe, objNeqFalse)
833{
834 nlohmann::json j = R"({"foo": "bar"})"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930835 DBusValueVariant v = false;
Brad Bishop6660e2a2020-08-28 10:44:41 -0400836 EXPECT_FALSE(matchProbe(j, v));
837}
838
839TEST(MatchProbe, objNeqTrue)
840{
841 nlohmann::json j = R"({"foo": "bar"})"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930842 DBusValueVariant v = true;
Brad Bishop6660e2a2020-08-28 10:44:41 -0400843 EXPECT_FALSE(matchProbe(j, v));
844}
845
846TEST(MatchProbe, objNeqUint8)
847{
848 nlohmann::json j = R"({"foo": "bar"})"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930849 DBusValueVariant v = uint8_t(1);
Brad Bishop6660e2a2020-08-28 10:44:41 -0400850 EXPECT_FALSE(matchProbe(j, v));
851}
852
853TEST(MatchProbe, objNeqInt32)
854{
855 nlohmann::json j = R"({"foo": "bar"})"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930856 DBusValueVariant v = int32_t(-1);
Brad Bishop6660e2a2020-08-28 10:44:41 -0400857 EXPECT_FALSE(matchProbe(j, v));
858}
859
860TEST(MatchProbe, objNeqDouble)
861{
862 nlohmann::json j = R"({"foo": "bar"})"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930863 DBusValueVariant v = double(1.1);
Brad Bishop6660e2a2020-08-28 10:44:41 -0400864 EXPECT_FALSE(matchProbe(j, v));
865}
Brad Bishopc776c412020-08-28 10:45:25 -0400866
Brad Bishopcd1868e2020-08-28 17:58:52 -0400867TEST(MatchProbe, objNeqArray)
868{
869 nlohmann::json j = R"({"foo": "bar"})"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930870 DBusValueVariant v = std::vector<uint8_t>{1, 2};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400871 EXPECT_FALSE(matchProbe(j, v));
872}
873
Brad Bishopc776c412020-08-28 10:45:25 -0400874TEST(MatchProbe, nullNeqString)
875{
876 nlohmann::json j = R"(null)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930877 DBusValueVariant v = "hello"s;
Brad Bishopc776c412020-08-28 10:45:25 -0400878 EXPECT_FALSE(matchProbe(j, v));
879}
880
881TEST(MatchProbe, nullNeqFalse)
882{
883 nlohmann::json j = R"(null)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930884 DBusValueVariant v = false;
Brad Bishopc776c412020-08-28 10:45:25 -0400885 EXPECT_FALSE(matchProbe(j, v));
886}
887
888TEST(MatchProbe, nullNeqTrue)
889{
890 nlohmann::json j = R"(null)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930891 DBusValueVariant v = true;
Brad Bishopc776c412020-08-28 10:45:25 -0400892 EXPECT_FALSE(matchProbe(j, v));
893}
894
895TEST(MatchProbe, nullNeqUint8)
896{
897 nlohmann::json j = R"(null)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930898 DBusValueVariant v = uint8_t(1);
Brad Bishopc776c412020-08-28 10:45:25 -0400899 EXPECT_FALSE(matchProbe(j, v));
900}
901
902TEST(MatchProbe, nullNeqInt32)
903{
904 nlohmann::json j = R"(null)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930905 DBusValueVariant v = int32_t(-1);
Brad Bishopc776c412020-08-28 10:45:25 -0400906 EXPECT_FALSE(matchProbe(j, v));
907}
908
909TEST(MatchProbe, nullNeqDouble)
910{
911 nlohmann::json j = R"(null)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930912 DBusValueVariant v = double(1.1);
Brad Bishopc776c412020-08-28 10:45:25 -0400913 EXPECT_FALSE(matchProbe(j, v));
914}
Brad Bishopcd1868e2020-08-28 17:58:52 -0400915
916TEST(MatchProbe, nullNeqArray)
917{
918 nlohmann::json j = R"(null)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930919 DBusValueVariant v = std::vector<uint8_t>{};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400920 EXPECT_FALSE(matchProbe(j, v));
921}