blob: 397861d0519cf70d422c5a1df756d0ee31a5f4ae [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"}};
Andrew Jeffery1983d2f2022-04-05 14:55:13 +093016 DBusInterface data;
James Feist481c5d52019-08-13 14:40:40 -070017 data["BUS"] = 23;
18
Ed Tanous77192692025-06-24 11:32:12 -070019 em_utils::templateCharReplace(j, data, 0);
James Feist481c5d52019-08-13 14:40:40 -070020
21 nlohmann::json expected = 23;
22 EXPECT_EQ(expected, j["foo"]);
23}
24
25TEST(TemplateCharReplace, replaceOneStr)
26{
27 nlohmann::json j = {{"foo", "$TEST"}};
Andrew Jeffery1983d2f2022-04-05 14:55:13 +093028 DBusInterface data;
James Feist481c5d52019-08-13 14:40:40 -070029 data["TEST"] = std::string("Test");
30
Ed Tanous77192692025-06-24 11:32:12 -070031 em_utils::templateCharReplace(j, data, 0);
James Feist481c5d52019-08-13 14:40:40 -070032
33 nlohmann::json expected = "Test";
34 EXPECT_EQ(expected, j["foo"]);
35}
36
37TEST(TemplateCharReplace, replaceSecondStr)
38{
39 nlohmann::json j = {{"foo", "the $TEST"}};
Andrew Jeffery1983d2f2022-04-05 14:55:13 +093040 DBusInterface data;
James Feist481c5d52019-08-13 14:40:40 -070041 data["TEST"] = std::string("Test");
42
Ed Tanous77192692025-06-24 11:32:12 -070043 em_utils::templateCharReplace(j, data, 0);
James Feist481c5d52019-08-13 14:40:40 -070044
45 nlohmann::json expected = "the Test";
46 EXPECT_EQ(expected, j["foo"]);
47}
48
James Feist481c5d52019-08-13 14:40:40 -070049TEST(TemplateCharReplace, replaceMiddleStr)
50{
51 nlohmann::json j = {{"foo", "the $TEST worked"}};
Andrew Jeffery1983d2f2022-04-05 14:55:13 +093052 DBusInterface data;
James Feist481c5d52019-08-13 14:40:40 -070053 data["TEST"] = std::string("Test");
54
Ed Tanous77192692025-06-24 11:32:12 -070055 em_utils::templateCharReplace(j, data, 0);
James Feist481c5d52019-08-13 14:40:40 -070056
57 nlohmann::json expected = "the Test worked";
58 EXPECT_EQ(expected, j["foo"]);
59}
James Feist481c5d52019-08-13 14:40:40 -070060
61TEST(TemplateCharReplace, replaceLastStr)
62{
63 nlohmann::json j = {{"foo", "the Test $TEST"}};
Andrew Jeffery1983d2f2022-04-05 14:55:13 +093064 DBusInterface data;
James Feist481c5d52019-08-13 14:40:40 -070065 data["TEST"] = 23;
66
Ed Tanous77192692025-06-24 11:32:12 -070067 em_utils::templateCharReplace(j, data, 0);
James Feist481c5d52019-08-13 14:40:40 -070068
69 nlohmann::json expected = "the Test 23";
70 EXPECT_EQ(expected, j["foo"]);
71}
72
73TEST(TemplateCharReplace, increment)
74{
75 nlohmann::json j = {{"foo", "3 plus 1 equals $TEST + 1"}};
Andrew Jeffery1983d2f2022-04-05 14:55:13 +093076 DBusInterface data;
James Feist481c5d52019-08-13 14:40:40 -070077 data["TEST"] = 3;
78
Ed Tanous77192692025-06-24 11:32:12 -070079 em_utils::templateCharReplace(j, data, 0);
James Feist481c5d52019-08-13 14:40:40 -070080
81 nlohmann::json expected = "3 plus 1 equals 4";
82 EXPECT_EQ(expected, j["foo"]);
83}
84
85TEST(TemplateCharReplace, decrement)
86{
87 nlohmann::json j = {{"foo", "3 minus 1 equals $TEST - 1 !"}};
Andrew Jeffery1983d2f2022-04-05 14:55:13 +093088 DBusInterface data;
James Feist481c5d52019-08-13 14:40:40 -070089 data["TEST"] = 3;
90
Ed Tanous77192692025-06-24 11:32:12 -070091 em_utils::templateCharReplace(j, data, 0);
James Feist481c5d52019-08-13 14:40:40 -070092
93 nlohmann::json expected = "3 minus 1 equals 2 !";
94 EXPECT_EQ(expected, j["foo"]);
95}
96
97TEST(TemplateCharReplace, modulus)
98{
99 nlohmann::json j = {{"foo", "3 mod 2 equals $TEST % 2"}};
Andrew Jeffery1983d2f2022-04-05 14:55:13 +0930100 DBusInterface data;
James Feist481c5d52019-08-13 14:40:40 -0700101 data["TEST"] = 3;
102
Ed Tanous77192692025-06-24 11:32:12 -0700103 em_utils::templateCharReplace(j, data, 0);
James Feist481c5d52019-08-13 14:40:40 -0700104
105 nlohmann::json expected = "3 mod 2 equals 1";
106 EXPECT_EQ(expected, j["foo"]);
107}
108
109TEST(TemplateCharReplace, multiply)
110{
111 nlohmann::json j = {{"foo", "3 * 2 equals $TEST * 2"}};
Andrew Jeffery1983d2f2022-04-05 14:55:13 +0930112 DBusInterface data;
James Feist481c5d52019-08-13 14:40:40 -0700113 data["TEST"] = 3;
114
Ed Tanous77192692025-06-24 11:32:12 -0700115 em_utils::templateCharReplace(j, data, 0);
James Feist481c5d52019-08-13 14:40:40 -0700116
117 nlohmann::json expected = "3 * 2 equals 6";
118 EXPECT_EQ(expected, j["foo"]);
119}
120
121TEST(TemplateCharReplace, divide)
122{
123 nlohmann::json j = {{"foo", "4 / 2 equals $TEST / 2"}};
Andrew Jeffery1983d2f2022-04-05 14:55:13 +0930124 DBusInterface data;
James Feist481c5d52019-08-13 14:40:40 -0700125 data["TEST"] = 4;
126
Ed Tanous77192692025-06-24 11:32:12 -0700127 em_utils::templateCharReplace(j, data, 0);
James Feist481c5d52019-08-13 14:40:40 -0700128
129 nlohmann::json expected = "4 / 2 equals 2";
130 EXPECT_EQ(expected, j["foo"]);
James Feist8c20feb2019-08-14 15:10:11 -0700131}
132
133TEST(TemplateCharReplace, multiMath)
134{
135 nlohmann::json j = {{"foo", "4 * 2 % 6 equals $TEST * 2 % 6"}};
Andrew Jeffery1983d2f2022-04-05 14:55:13 +0930136 DBusInterface data;
James Feist8c20feb2019-08-14 15:10:11 -0700137 data["TEST"] = 4;
138
Ed Tanous77192692025-06-24 11:32:12 -0700139 em_utils::templateCharReplace(j, data, 0);
James Feist8c20feb2019-08-14 15:10:11 -0700140
141 nlohmann::json expected = "4 * 2 % 6 equals 2";
142 EXPECT_EQ(expected, j["foo"]);
143}
144
145TEST(TemplateCharReplace, twoReplacements)
146{
147 nlohmann::json j = {{"foo", "$FOO $BAR"}};
Andrew Jeffery1983d2f2022-04-05 14:55:13 +0930148 DBusInterface data;
James Feist8c20feb2019-08-14 15:10:11 -0700149 data["FOO"] = std::string("foo");
150 data["BAR"] = std::string("bar");
151
Ed Tanous77192692025-06-24 11:32:12 -0700152 em_utils::templateCharReplace(j, data, 0);
James Feist8c20feb2019-08-14 15:10:11 -0700153
154 nlohmann::json expected = "foo bar";
155 EXPECT_EQ(expected, j["foo"]);
156}
157
158TEST(TemplateCharReplace, twoReplacementsWithMath)
159{
160 nlohmann::json j = {{"foo", "4 / 2 equals $TEST / 2 $BAR"}};
Andrew Jeffery1983d2f2022-04-05 14:55:13 +0930161 DBusInterface data;
James Feist8c20feb2019-08-14 15:10:11 -0700162 data["TEST"] = 4;
163 data["BAR"] = std::string("bar");
164
Ed Tanous77192692025-06-24 11:32:12 -0700165 em_utils::templateCharReplace(j, data, 0);
James Feist8c20feb2019-08-14 15:10:11 -0700166
167 nlohmann::json expected = "4 / 2 equals 2 bar";
Zhikui Rena0d1b3f2021-10-05 16:21:56 -0700168}
169
170TEST(TemplateCharReplace, twoReplacementsWithMath2)
171{
172 nlohmann::json j = {{"foo", "4 / 2 equals $ADDRESS / 2 $BAR"}};
Andrew Jeffery1983d2f2022-04-05 14:55:13 +0930173 DBusInterface data;
Zhikui Rena0d1b3f2021-10-05 16:21:56 -0700174 data["ADDRESS"] = 4;
175 data["BAR"] = std::string("bar");
176
Ed Tanous77192692025-06-24 11:32:12 -0700177 em_utils::templateCharReplace(j, data, 0);
Zhikui Rena0d1b3f2021-10-05 16:21:56 -0700178
179 nlohmann::json expected = "4 / 2 equals 2 bar";
James Feist8c20feb2019-08-14 15:10:11 -0700180 EXPECT_EQ(expected, j["foo"]);
James Feistb0097d42019-08-15 09:24:13 -0700181}
182
183TEST(TemplateCharReplace, hexAndWrongCase)
184{
185 nlohmann::json j = {{"Address", "0x54"},
186 {"Bus", 15},
187 {"Name", "$bus sensor 0"},
188 {"Type", "SomeType"}};
189
Andrew Jeffery1983d2f2022-04-05 14:55:13 +0930190 DBusInterface data;
James Feistb0097d42019-08-15 09:24:13 -0700191 data["BUS"] = 15;
192
193 for (auto it = j.begin(); it != j.end(); it++)
194 {
Ed Tanous77192692025-06-24 11:32:12 -0700195 em_utils::templateCharReplace(j, data, 0);
James Feistb0097d42019-08-15 09:24:13 -0700196 }
197 nlohmann::json expected = {{"Address", 84},
198 {"Bus", 15},
199 {"Name", "15 sensor 0"},
200 {"Type", "SomeType"}};
201 EXPECT_EQ(expected, j);
202}
203
204TEST(TemplateCharReplace, replaceSecondAsInt)
205{
206 nlohmann::json j = {{"foo", "twelve is $TEST"}};
Andrew Jeffery1983d2f2022-04-05 14:55:13 +0930207 DBusInterface data;
James Feistb0097d42019-08-15 09:24:13 -0700208 data["test"] = 12;
209
Ed Tanous77192692025-06-24 11:32:12 -0700210 em_utils::templateCharReplace(j, data, 0);
James Feistb0097d42019-08-15 09:24:13 -0700211
212 nlohmann::json expected = "twelve is 12";
213 EXPECT_EQ(expected, j["foo"]);
214}
James Feistc296c802019-08-28 09:26:47 -0700215
216TEST(TemplateCharReplace, singleHex)
217{
218 nlohmann::json j = {{"foo", "0x54"}};
Andrew Jeffery1983d2f2022-04-05 14:55:13 +0930219 DBusInterface data;
James Feistc296c802019-08-28 09:26:47 -0700220
Ed Tanous77192692025-06-24 11:32:12 -0700221 em_utils::templateCharReplace(j, data, 0);
James Feistc296c802019-08-28 09:26:47 -0700222
223 nlohmann::json expected = 84;
224 EXPECT_EQ(expected, j["foo"]);
225}
Brad Bishop9d2ef082020-08-26 15:17:55 -0400226
Chau Ly79629442025-08-20 10:27:20 +0000227TEST(TemplateCharReplace, leftOverTemplateVars)
228{
229 nlohmann::json j = {{"foo", "$EXISTENT_VAR and $NON_EXISTENT_VAR"}};
Chau Ly79629442025-08-20 10:27:20 +0000230
231 DBusInterface data;
232 data["EXISTENT_VAR"] = std::string("Replaced");
233
234 DBusObject object;
235 object["PATH"] = data;
236
Ed Tanous77192692025-06-24 11:32:12 -0700237 em_utils::templateCharReplace(j, object, 0);
Chau Ly79629442025-08-20 10:27:20 +0000238
239 nlohmann::json expected = "Replaced and ";
240 EXPECT_EQ(expected, j["foo"]);
241}
242
243TEST(HandleLeftOverTemplateVars, replaceLeftOverTemplateVar)
244{
245 nlohmann::json j = {{"foo", "the Test $TEST is $TESTED"}};
Chau Ly79629442025-08-20 10:27:20 +0000246
Ed Tanous77192692025-06-24 11:32:12 -0700247 em_utils::handleLeftOverTemplateVars(j);
Chau Ly79629442025-08-20 10:27:20 +0000248
249 nlohmann::json expected = "the Test is ";
250 EXPECT_EQ(expected, j["foo"]);
251}
252
Brad Bishop9d2ef082020-08-26 15:17:55 -0400253TEST(MatchProbe, stringEqString)
254{
255 nlohmann::json j = R"("foo")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930256 DBusValueVariant v = "foo"s;
Brad Bishop9d2ef082020-08-26 15:17:55 -0400257 EXPECT_TRUE(matchProbe(j, v));
258}
259
260TEST(MatchProbe, stringRegexEqString)
261{
262 nlohmann::json j = R"("foo*")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930263 DBusValueVariant v = "foobar"s;
Brad Bishop9d2ef082020-08-26 15:17:55 -0400264 EXPECT_TRUE(matchProbe(j, v));
265}
266
267TEST(MatchProbe, stringNeqString)
268{
269 nlohmann::json j = R"("foobar")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930270 DBusValueVariant v = "foo"s;
Brad Bishop9d2ef082020-08-26 15:17:55 -0400271 EXPECT_FALSE(matchProbe(j, v));
272}
273
274TEST(MatchProbe, stringRegexError)
275{
276 nlohmann::json j = R"("foo[")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930277 DBusValueVariant v = "foobar"s;
Brad Bishop5d525412020-08-26 08:50:50 -0400278 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop9d2ef082020-08-26 15:17:55 -0400279}
280
Patrick Rudolph1c39d7b2023-09-21 15:50:20 +0200281TEST(MatchProbe, stringRegexNotPrefix)
282{
283 nlohmann::json j = R"("foo(?!bar)...foo")"_json;
284 DBusValueVariant v1 = "foobarfoo"s;
285 DBusValueVariant v2 = "foofoofoo"s;
286 EXPECT_FALSE(matchProbe(j, v1));
287 EXPECT_TRUE(matchProbe(j, v2));
288}
289
Brad Bishop5d525412020-08-26 08:50:50 -0400290TEST(MatchProbe, stringZeroNeqFalse)
Brad Bishop9d2ef082020-08-26 15:17:55 -0400291{
292 nlohmann::json j = R"("0")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930293 DBusValueVariant v = false;
Brad Bishop5d525412020-08-26 08:50:50 -0400294 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop9d2ef082020-08-26 15:17:55 -0400295}
296
Brad Bishop5d525412020-08-26 08:50:50 -0400297TEST(MatchProbe, stringOneNeqTrue)
Brad Bishop9d2ef082020-08-26 15:17:55 -0400298{
299 nlohmann::json j = R"("1")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930300 DBusValueVariant v = true;
Brad Bishop5d525412020-08-26 08:50:50 -0400301 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop9d2ef082020-08-26 15:17:55 -0400302}
303
304TEST(MatchProbe, stringElevenNeqTrue)
305{
306 nlohmann::json j = R"("11")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930307 DBusValueVariant v = true;
Brad Bishop9d2ef082020-08-26 15:17:55 -0400308 EXPECT_FALSE(matchProbe(j, v));
309}
310
311TEST(MatchProbe, stringFalseNeqFalse)
312{
313 nlohmann::json j = R"("false")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930314 DBusValueVariant v = false;
Brad Bishop9d2ef082020-08-26 15:17:55 -0400315 EXPECT_FALSE(matchProbe(j, v));
316}
317
318TEST(MatchProbe, stringTrueNeqTrue)
319{
320 nlohmann::json j = R"("true")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930321 DBusValueVariant v = true;
Brad Bishop9d2ef082020-08-26 15:17:55 -0400322 EXPECT_FALSE(matchProbe(j, v));
323}
324
325TEST(MatchProbe, stringFalseNeqTrue)
326{
327 nlohmann::json j = R"("false")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930328 DBusValueVariant v = true;
Brad Bishop9d2ef082020-08-26 15:17:55 -0400329 EXPECT_FALSE(matchProbe(j, v));
330}
331
Brad Bishop5d525412020-08-26 08:50:50 -0400332TEST(MatchProbe, stringNeqUint8)
Brad Bishop9d2ef082020-08-26 15:17:55 -0400333{
334 nlohmann::json j = R"("255")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930335 DBusValueVariant v = uint8_t(255);
Brad Bishop5d525412020-08-26 08:50:50 -0400336 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop9d2ef082020-08-26 15:17:55 -0400337}
338
339TEST(MatchProbe, stringNeqUint8Overflow)
340{
341 nlohmann::json j = R"("65535")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930342 DBusValueVariant v = uint8_t(255);
Brad Bishop9d2ef082020-08-26 15:17:55 -0400343 EXPECT_FALSE(matchProbe(j, v));
344}
345
346TEST(MatchProbe, stringFalseNeqUint8Zero)
347{
348 nlohmann::json j = R"("false")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930349 DBusValueVariant v = uint8_t(0);
Brad Bishop9d2ef082020-08-26 15:17:55 -0400350 EXPECT_FALSE(matchProbe(j, v));
351}
352
353TEST(MatchProbe, stringTrueNeqUint8Zero)
354{
355 nlohmann::json j = R"("true")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930356 DBusValueVariant v = uint8_t(1);
Brad Bishop9d2ef082020-08-26 15:17:55 -0400357 EXPECT_FALSE(matchProbe(j, v));
358}
359
Brad Bishop5d525412020-08-26 08:50:50 -0400360TEST(MatchProbe, stringNeqUint32)
Brad Bishop9d2ef082020-08-26 15:17:55 -0400361{
362 nlohmann::json j = R"("11")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930363 DBusValueVariant v = uint32_t(11);
Brad Bishop9d2ef082020-08-26 15:17:55 -0400364 EXPECT_FALSE(matchProbe(j, v));
365}
366
Brad Bishop9d2ef082020-08-26 15:17:55 -0400367TEST(MatchProbe, stringNeqInt32)
368{
Brad Bishop5d525412020-08-26 08:50:50 -0400369 nlohmann::json j = R"("-11")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930370 DBusValueVariant v = int32_t(-11);
Brad Bishop9d2ef082020-08-26 15:17:55 -0400371 EXPECT_FALSE(matchProbe(j, v));
372}
373
Brad Bishop5d525412020-08-26 08:50:50 -0400374TEST(MatchProbe, stringRegexNeqInt32)
Brad Bishop9d2ef082020-08-26 15:17:55 -0400375{
376 nlohmann::json j = R"("1*4")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930377 DBusValueVariant v = int32_t(124);
Brad Bishop5d525412020-08-26 08:50:50 -0400378 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop9d2ef082020-08-26 15:17:55 -0400379}
380
381TEST(MatchProbe, stringNeqUint64)
382{
383 nlohmann::json j = R"("foo")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930384 DBusValueVariant v = uint64_t(65535);
Brad Bishop9d2ef082020-08-26 15:17:55 -0400385 EXPECT_FALSE(matchProbe(j, v));
386}
387
Brad Bishop9d2ef082020-08-26 15:17:55 -0400388TEST(MatchProbe, stringNeqDouble)
389{
Brad Bishop5d525412020-08-26 08:50:50 -0400390 nlohmann::json j = R"("123.4")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930391 DBusValueVariant v = double(123.4);
Brad Bishop9d2ef082020-08-26 15:17:55 -0400392 EXPECT_FALSE(matchProbe(j, v));
393}
394
395TEST(MatchProbe, stringNeqEmpty)
396{
397 nlohmann::json j = R"("-123.4")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930398 DBusValueVariant v;
Brad Bishop9d2ef082020-08-26 15:17:55 -0400399 EXPECT_FALSE(matchProbe(j, v));
400}
Brad Bishopc5eba592020-08-28 10:38:24 -0400401
Brad Bishopcd1868e2020-08-28 17:58:52 -0400402TEST(MatchProbe, stringNeqArray)
403{
404 nlohmann::json j = R"("-123.4")"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930405 DBusValueVariant v = std::vector<uint8_t>{1, 2};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400406 EXPECT_FALSE(matchProbe(j, v));
407}
408
Brad Bishop5d525412020-08-26 08:50:50 -0400409TEST(MatchProbe, boolNeqString)
Brad Bishopc5eba592020-08-28 10:38:24 -0400410{
411 nlohmann::json j = R"(false)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930412 DBusValueVariant v = "false"s;
Brad Bishop5d525412020-08-26 08:50:50 -0400413 EXPECT_FALSE(matchProbe(j, v));
Brad Bishopc5eba592020-08-28 10:38:24 -0400414}
415
416TEST(MatchProbe, trueEqTrue)
417{
418 nlohmann::json j = R"(true)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930419 DBusValueVariant v = true;
Brad Bishopc5eba592020-08-28 10:38:24 -0400420 EXPECT_TRUE(matchProbe(j, v));
421}
422
423TEST(MatchProbe, falseEqFalse)
424{
425 nlohmann::json j = R"(false)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930426 DBusValueVariant v = false;
Brad Bishopc5eba592020-08-28 10:38:24 -0400427 EXPECT_TRUE(matchProbe(j, v));
428}
429
430TEST(MatchProbe, trueNeqFalse)
431{
432 nlohmann::json j = R"(true)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930433 DBusValueVariant v = false;
Brad Bishopc5eba592020-08-28 10:38:24 -0400434 EXPECT_FALSE(matchProbe(j, v));
435}
436
437TEST(MatchProbe, trueNeqInt32Zero)
438{
439 nlohmann::json j = R"(true)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930440 DBusValueVariant v = int32_t(0);
Brad Bishopc5eba592020-08-28 10:38:24 -0400441 EXPECT_FALSE(matchProbe(j, v));
442}
443
444TEST(MatchProbe, trueNeqInt32NegativeOne)
445{
446 nlohmann::json j = R"(true)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930447 DBusValueVariant v = int32_t(-1);
Brad Bishopc5eba592020-08-28 10:38:24 -0400448 EXPECT_FALSE(matchProbe(j, v));
449}
450
451TEST(MatchProbe, falseNeqUint32One)
452{
453 nlohmann::json j = R"(false)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930454 DBusValueVariant v = uint32_t(1);
Brad Bishopc5eba592020-08-28 10:38:24 -0400455 EXPECT_FALSE(matchProbe(j, v));
456}
457
Brad Bishop5d525412020-08-26 08:50:50 -0400458TEST(MatchProbe, falseNeqUint32Zero)
Brad Bishopc5eba592020-08-28 10:38:24 -0400459{
460 nlohmann::json j = R"(false)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930461 DBusValueVariant v = uint32_t(0);
Brad Bishop5d525412020-08-26 08:50:50 -0400462 EXPECT_FALSE(matchProbe(j, v));
Brad Bishopc5eba592020-08-28 10:38:24 -0400463}
464
465TEST(MatchProbe, trueNeqDoubleNegativeOne)
466{
467 nlohmann::json j = R"(true)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930468 DBusValueVariant v = double(-1.1);
Brad Bishopc5eba592020-08-28 10:38:24 -0400469 EXPECT_FALSE(matchProbe(j, v));
470}
471
Brad Bishop5d525412020-08-26 08:50:50 -0400472TEST(MatchProbe, trueNeqDoubleOne)
Brad Bishopc5eba592020-08-28 10:38:24 -0400473{
474 nlohmann::json j = R"(true)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930475 DBusValueVariant v = double(1.0);
Brad Bishop5d525412020-08-26 08:50:50 -0400476 EXPECT_FALSE(matchProbe(j, v));
Brad Bishopc5eba592020-08-28 10:38:24 -0400477}
478
479TEST(MatchProbe, falseNeqDoubleOne)
480{
481 nlohmann::json j = R"(false)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930482 DBusValueVariant v = double(1.0);
Brad Bishopc5eba592020-08-28 10:38:24 -0400483 EXPECT_FALSE(matchProbe(j, v));
484}
485
Brad Bishop5d525412020-08-26 08:50:50 -0400486TEST(MatchProbe, falseNeqDoubleZero)
Brad Bishopc5eba592020-08-28 10:38:24 -0400487{
488 nlohmann::json j = R"(false)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930489 DBusValueVariant v = double(0.0);
Brad Bishop5d525412020-08-26 08:50:50 -0400490 EXPECT_FALSE(matchProbe(j, v));
Brad Bishopc5eba592020-08-28 10:38:24 -0400491}
492
Brad Bishop5d525412020-08-26 08:50:50 -0400493TEST(MatchProbe, falseNeqEmpty)
Brad Bishopc5eba592020-08-28 10:38:24 -0400494{
495 nlohmann::json j = R"(false)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930496 DBusValueVariant v;
Brad Bishop5d525412020-08-26 08:50:50 -0400497 EXPECT_FALSE(matchProbe(j, v));
Brad Bishopc5eba592020-08-28 10:38:24 -0400498}
499
Brad Bishop5d525412020-08-26 08:50:50 -0400500TEST(MatchProbe, trueNeqEmpty)
Brad Bishopc5eba592020-08-28 10:38:24 -0400501{
502 nlohmann::json j = R"(true)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930503 DBusValueVariant v;
Brad Bishop5d525412020-08-26 08:50:50 -0400504 EXPECT_FALSE(matchProbe(j, v));
Brad Bishopc5eba592020-08-28 10:38:24 -0400505}
Brad Bishopc2af5312020-08-28 10:39:49 -0400506
Brad Bishopcd1868e2020-08-28 17:58:52 -0400507TEST(MatchProbe, trueNeqArray)
508{
509 nlohmann::json j = R"(true)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930510 DBusValueVariant v = std::vector<uint8_t>{1, 2};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400511 EXPECT_FALSE(matchProbe(j, v));
512}
513
Brad Bishop5d525412020-08-26 08:50:50 -0400514TEST(MatchProbe, uintNeqString)
Brad Bishopc2af5312020-08-28 10:39:49 -0400515{
516 nlohmann::json j = R"(11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930517 DBusValueVariant v = "11"s;
Brad Bishop5d525412020-08-26 08:50:50 -0400518 EXPECT_FALSE(matchProbe(j, v));
Brad Bishopc2af5312020-08-28 10:39:49 -0400519}
520
521TEST(MatchProbe, uintNeqTrue)
522{
Brad Bishop5d525412020-08-26 08:50:50 -0400523 nlohmann::json j = R"(1)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930524 DBusValueVariant v = true;
Brad Bishopc2af5312020-08-28 10:39:49 -0400525 EXPECT_FALSE(matchProbe(j, v));
526}
527
Brad Bishop5d525412020-08-26 08:50:50 -0400528TEST(MatchProbe, uintNeqFalse)
529{
530 nlohmann::json j = R"(0)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930531 DBusValueVariant v = false;
Brad Bishop5d525412020-08-26 08:50:50 -0400532 EXPECT_FALSE(matchProbe(j, v));
533}
534
Brad Bishopc2af5312020-08-28 10:39:49 -0400535TEST(MatchProbe, uintEqUint8)
536{
537 nlohmann::json j = R"(11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930538 DBusValueVariant v = uint8_t(11);
Brad Bishopc2af5312020-08-28 10:39:49 -0400539 EXPECT_TRUE(matchProbe(j, v));
540}
541
542TEST(MatchProbe, uintNeqUint8)
543{
544 nlohmann::json j = R"(11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930545 DBusValueVariant v = uint8_t(12);
Brad Bishopc2af5312020-08-28 10:39:49 -0400546 EXPECT_FALSE(matchProbe(j, v));
547}
548
549TEST(MatchProbe, uintNeqUint8Overflow)
550{
551 nlohmann::json j = R"(65535)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930552 DBusValueVariant v = uint8_t(255);
Brad Bishopc2af5312020-08-28 10:39:49 -0400553 EXPECT_FALSE(matchProbe(j, v));
554}
555
556TEST(MatchProbe, uintEqInt8)
557{
558 nlohmann::json j = R"(11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930559 DBusValueVariant v = int8_t(11);
Brad Bishopc2af5312020-08-28 10:39:49 -0400560 EXPECT_TRUE(matchProbe(j, v));
561}
562
563TEST(MatchProbe, uintEqDouble)
564{
565 nlohmann::json j = R"(11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930566 DBusValueVariant v = double(11.0);
Brad Bishopc2af5312020-08-28 10:39:49 -0400567 EXPECT_TRUE(matchProbe(j, v));
568}
569
Brad Bishop5d525412020-08-26 08:50:50 -0400570TEST(MatchProbe, uintNeqDouble)
Brad Bishopc2af5312020-08-28 10:39:49 -0400571{
572 nlohmann::json j = R"(11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930573 DBusValueVariant v = double(11.7);
Brad Bishop5d525412020-08-26 08:50:50 -0400574 EXPECT_FALSE(matchProbe(j, v));
Brad Bishopc2af5312020-08-28 10:39:49 -0400575}
576
Brad Bishop5d525412020-08-26 08:50:50 -0400577TEST(MatchProbe, uintNeqEmpty)
Brad Bishopc2af5312020-08-28 10:39:49 -0400578{
579 nlohmann::json j = R"(11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930580 DBusValueVariant v;
Brad Bishop5d525412020-08-26 08:50:50 -0400581 EXPECT_FALSE(matchProbe(j, v));
Brad Bishopc2af5312020-08-28 10:39:49 -0400582}
Brad Bishop667e0502020-08-28 10:41:40 -0400583
Brad Bishopcd1868e2020-08-28 17:58:52 -0400584TEST(MatchProbe, uintNeqArray)
585{
586 nlohmann::json j = R"(11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930587 DBusValueVariant v = std::vector<uint8_t>{11};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400588 EXPECT_FALSE(matchProbe(j, v));
589}
590
Brad Bishop5d525412020-08-26 08:50:50 -0400591TEST(MatchProbe, intNeqString)
Brad Bishop667e0502020-08-28 10:41:40 -0400592{
593 nlohmann::json j = R"(-11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930594 DBusValueVariant v = "-11"s;
Brad Bishop5d525412020-08-26 08:50:50 -0400595 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop667e0502020-08-28 10:41:40 -0400596}
597
598TEST(MatchProbe, intNeqTrue)
599{
600 nlohmann::json j = R"(-1)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930601 DBusValueVariant v = true;
Brad Bishop667e0502020-08-28 10:41:40 -0400602 EXPECT_FALSE(matchProbe(j, v));
603}
604
605TEST(MatchProbe, intNeqUint8)
606{
607 nlohmann::json j = R"(-11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930608 DBusValueVariant v = uint8_t(11);
Brad Bishop667e0502020-08-28 10:41:40 -0400609 EXPECT_FALSE(matchProbe(j, v));
610}
611
612TEST(MatchProbe, intEqInt8)
613{
614 nlohmann::json j = R"(-11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930615 DBusValueVariant v = int8_t(-11);
Brad Bishop667e0502020-08-28 10:41:40 -0400616 EXPECT_TRUE(matchProbe(j, v));
617}
618
619TEST(MatchProbe, intNeqDouble)
620{
621 nlohmann::json j = R"(-124)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930622 DBusValueVariant v = double(-123.0);
Brad Bishop667e0502020-08-28 10:41:40 -0400623 EXPECT_FALSE(matchProbe(j, v));
624}
625
626TEST(MatchProbe, intEqDouble)
627{
628 nlohmann::json j = R"(-11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930629 DBusValueVariant v = double(-11.0);
Brad Bishop667e0502020-08-28 10:41:40 -0400630 EXPECT_TRUE(matchProbe(j, v));
631}
632
Brad Bishop5d525412020-08-26 08:50:50 -0400633TEST(MatchProbe, intNeqDoubleRound)
Brad Bishop667e0502020-08-28 10:41:40 -0400634{
635 nlohmann::json j = R"(-11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930636 DBusValueVariant v = double(-11.7);
Brad Bishop5d525412020-08-26 08:50:50 -0400637 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop667e0502020-08-28 10:41:40 -0400638}
639
Brad Bishop5d525412020-08-26 08:50:50 -0400640TEST(MatchProbe, intNeqEmpty)
Brad Bishop667e0502020-08-28 10:41:40 -0400641{
642 nlohmann::json j = R"(-11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930643 DBusValueVariant v;
Brad Bishop5d525412020-08-26 08:50:50 -0400644 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop667e0502020-08-28 10:41:40 -0400645}
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400646
Brad Bishopcd1868e2020-08-28 17:58:52 -0400647TEST(MatchProbe, intNeqArray)
648{
649 nlohmann::json j = R"(-11)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930650 DBusValueVariant v = std::vector<uint8_t>{11};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400651 EXPECT_FALSE(matchProbe(j, v));
652}
653
Brad Bishop5d525412020-08-26 08:50:50 -0400654TEST(MatchProbe, doubleNeqString)
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400655{
656 nlohmann::json j = R"(0.0)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930657 DBusValueVariant v = "0.0"s;
Brad Bishop5d525412020-08-26 08:50:50 -0400658 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400659}
660
Brad Bishop5d525412020-08-26 08:50:50 -0400661TEST(MatchProbe, doubleNeqFalse)
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400662{
663 nlohmann::json j = R"(0.0)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930664 DBusValueVariant v = false;
Brad Bishop5d525412020-08-26 08:50:50 -0400665 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400666}
667
668TEST(MatchProbe, doubleNeqTrue)
669{
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400670 nlohmann::json j = R"(1.0)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930671 DBusValueVariant v = true;
Brad Bishop5d525412020-08-26 08:50:50 -0400672 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400673}
674
675TEST(MatchProbe, doubleEqInt32)
676{
677 nlohmann::json j = R"(-124.0)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930678 DBusValueVariant v = int32_t(-124);
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400679 EXPECT_TRUE(matchProbe(j, v));
680}
681
682TEST(MatchProbe, doubleNeqInt32)
683{
684 nlohmann::json j = R"(-124.0)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930685 DBusValueVariant v = int32_t(-123);
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400686 EXPECT_FALSE(matchProbe(j, v));
687}
688
689TEST(MatchProbe, doubleRoundNeqInt)
690{
691 nlohmann::json j = R"(124.7)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930692 DBusValueVariant v = int32_t(124);
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400693 EXPECT_FALSE(matchProbe(j, v));
694}
695TEST(MatchProbe, doubleEqDouble)
696{
697 nlohmann::json j = R"(-124.2)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930698 DBusValueVariant v = double(-124.2);
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400699 EXPECT_TRUE(matchProbe(j, v));
700}
701
702TEST(MatchProbe, doubleNeqDouble)
703{
704 nlohmann::json j = R"(-124.3)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930705 DBusValueVariant v = double(-124.2);
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400706 EXPECT_FALSE(matchProbe(j, v));
707}
708
Brad Bishop5d525412020-08-26 08:50:50 -0400709TEST(MatchProbe, doubleNeqEmpty)
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400710{
711 nlohmann::json j = R"(-11.0)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930712 DBusValueVariant v;
Brad Bishop5d525412020-08-26 08:50:50 -0400713 EXPECT_FALSE(matchProbe(j, v));
Brad Bishop3bd8e8d2020-08-28 10:42:27 -0400714}
Brad Bishopd14c2e22020-08-28 10:43:40 -0400715
Brad Bishopcd1868e2020-08-28 17:58:52 -0400716TEST(MatchProbe, doubleNeqArray)
717{
718 nlohmann::json j = R"(-11.2)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930719 DBusValueVariant v = std::vector<uint8_t>{11};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400720 EXPECT_FALSE(matchProbe(j, v));
721}
722
Brad Bishopd14c2e22020-08-28 10:43:40 -0400723TEST(MatchProbe, arrayNeqString)
724{
725 nlohmann::json j = R"([1, 2])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930726 DBusValueVariant v = "hello"s;
Brad Bishopd14c2e22020-08-28 10:43:40 -0400727 EXPECT_FALSE(matchProbe(j, v));
728}
729
730TEST(MatchProbe, arrayNeqFalse)
731{
732 nlohmann::json j = R"([1, 2])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930733 DBusValueVariant v = false;
Brad Bishopd14c2e22020-08-28 10:43:40 -0400734 EXPECT_FALSE(matchProbe(j, v));
735}
736
737TEST(MatchProbe, arrayNeqTrue)
738{
739 nlohmann::json j = R"([1, 2])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930740 DBusValueVariant v = true;
Brad Bishopd14c2e22020-08-28 10:43:40 -0400741 EXPECT_FALSE(matchProbe(j, v));
742}
743
744TEST(MatchProbe, arrayNeqUint8)
745{
746 nlohmann::json j = R"([1, 2])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930747 DBusValueVariant v = uint8_t(1);
Brad Bishopd14c2e22020-08-28 10:43:40 -0400748 EXPECT_FALSE(matchProbe(j, v));
749}
750
751TEST(MatchProbe, arrayNeqInt32)
752{
753 nlohmann::json j = R"([1, 2])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930754 DBusValueVariant v = int32_t(-1);
Brad Bishopd14c2e22020-08-28 10:43:40 -0400755 EXPECT_FALSE(matchProbe(j, v));
756}
757
758TEST(MatchProbe, arrayNeqDouble)
759{
760 nlohmann::json j = R"([1, 2])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930761 DBusValueVariant v = double(1.1);
Brad Bishopd14c2e22020-08-28 10:43:40 -0400762 EXPECT_FALSE(matchProbe(j, v));
763}
Brad Bishop6660e2a2020-08-28 10:44:41 -0400764
Brad Bishopcd1868e2020-08-28 17:58:52 -0400765TEST(MatchProbe, arrayEqArray)
766{
767 nlohmann::json j = R"([1, 2])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930768 DBusValueVariant v = std::vector<uint8_t>{1, 2};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400769 EXPECT_TRUE(matchProbe(j, v));
770}
771
772TEST(MatchProbe, arrayNeqArrayDiffSize1)
773{
774 nlohmann::json j = R"([1, 2, 3])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930775 DBusValueVariant v = std::vector<uint8_t>{1, 2};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400776 EXPECT_FALSE(matchProbe(j, v));
777}
778
779TEST(MatchProbe, arrayNeqArrayDiffSize2)
780{
781 nlohmann::json j = R"([1, 2])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930782 DBusValueVariant v = std::vector<uint8_t>{1, 2, 3};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400783 EXPECT_FALSE(matchProbe(j, v));
784}
785
786TEST(MatchProbe, emptyArrayEqEmptyArray)
787{
788 nlohmann::json j = R"([])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930789 DBusValueVariant v = std::vector<uint8_t>{};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400790 EXPECT_TRUE(matchProbe(j, v));
791}
792
793TEST(MatchProbe, emptyArrayNeqArray)
794{
795 nlohmann::json j = R"([])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930796 DBusValueVariant v = std::vector<uint8_t>{1};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400797 EXPECT_FALSE(matchProbe(j, v));
798}
799
800TEST(MatchProbe, arrayNeqEmptyArray)
801{
802 nlohmann::json j = R"([1])"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930803 DBusValueVariant v = std::vector<uint8_t>{};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400804 EXPECT_FALSE(matchProbe(j, v));
805}
806
Brad Bishop6660e2a2020-08-28 10:44:41 -0400807TEST(MatchProbe, objNeqString)
808{
809 nlohmann::json j = R"({"foo": "bar"})"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930810 DBusValueVariant v = "hello"s;
Brad Bishop6660e2a2020-08-28 10:44:41 -0400811 EXPECT_FALSE(matchProbe(j, v));
812}
813
814TEST(MatchProbe, objNeqFalse)
815{
816 nlohmann::json j = R"({"foo": "bar"})"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930817 DBusValueVariant v = false;
Brad Bishop6660e2a2020-08-28 10:44:41 -0400818 EXPECT_FALSE(matchProbe(j, v));
819}
820
821TEST(MatchProbe, objNeqTrue)
822{
823 nlohmann::json j = R"({"foo": "bar"})"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930824 DBusValueVariant v = true;
Brad Bishop6660e2a2020-08-28 10:44:41 -0400825 EXPECT_FALSE(matchProbe(j, v));
826}
827
828TEST(MatchProbe, objNeqUint8)
829{
830 nlohmann::json j = R"({"foo": "bar"})"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930831 DBusValueVariant v = uint8_t(1);
Brad Bishop6660e2a2020-08-28 10:44:41 -0400832 EXPECT_FALSE(matchProbe(j, v));
833}
834
835TEST(MatchProbe, objNeqInt32)
836{
837 nlohmann::json j = R"({"foo": "bar"})"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930838 DBusValueVariant v = int32_t(-1);
Brad Bishop6660e2a2020-08-28 10:44:41 -0400839 EXPECT_FALSE(matchProbe(j, v));
840}
841
842TEST(MatchProbe, objNeqDouble)
843{
844 nlohmann::json j = R"({"foo": "bar"})"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930845 DBusValueVariant v = double(1.1);
Brad Bishop6660e2a2020-08-28 10:44:41 -0400846 EXPECT_FALSE(matchProbe(j, v));
847}
Brad Bishopc776c412020-08-28 10:45:25 -0400848
Brad Bishopcd1868e2020-08-28 17:58:52 -0400849TEST(MatchProbe, objNeqArray)
850{
851 nlohmann::json j = R"({"foo": "bar"})"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930852 DBusValueVariant v = std::vector<uint8_t>{1, 2};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400853 EXPECT_FALSE(matchProbe(j, v));
854}
855
Brad Bishopc776c412020-08-28 10:45:25 -0400856TEST(MatchProbe, nullNeqString)
857{
858 nlohmann::json j = R"(null)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930859 DBusValueVariant v = "hello"s;
Brad Bishopc776c412020-08-28 10:45:25 -0400860 EXPECT_FALSE(matchProbe(j, v));
861}
862
863TEST(MatchProbe, nullNeqFalse)
864{
865 nlohmann::json j = R"(null)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930866 DBusValueVariant v = false;
Brad Bishopc776c412020-08-28 10:45:25 -0400867 EXPECT_FALSE(matchProbe(j, v));
868}
869
870TEST(MatchProbe, nullNeqTrue)
871{
872 nlohmann::json j = R"(null)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930873 DBusValueVariant v = true;
Brad Bishopc776c412020-08-28 10:45:25 -0400874 EXPECT_FALSE(matchProbe(j, v));
875}
876
877TEST(MatchProbe, nullNeqUint8)
878{
879 nlohmann::json j = R"(null)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930880 DBusValueVariant v = uint8_t(1);
Brad Bishopc776c412020-08-28 10:45:25 -0400881 EXPECT_FALSE(matchProbe(j, v));
882}
883
884TEST(MatchProbe, nullNeqInt32)
885{
886 nlohmann::json j = R"(null)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930887 DBusValueVariant v = int32_t(-1);
Brad Bishopc776c412020-08-28 10:45:25 -0400888 EXPECT_FALSE(matchProbe(j, v));
889}
890
891TEST(MatchProbe, nullNeqDouble)
892{
893 nlohmann::json j = R"(null)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930894 DBusValueVariant v = double(1.1);
Brad Bishopc776c412020-08-28 10:45:25 -0400895 EXPECT_FALSE(matchProbe(j, v));
896}
Brad Bishopcd1868e2020-08-28 17:58:52 -0400897
898TEST(MatchProbe, nullNeqArray)
899{
900 nlohmann::json j = R"(null)"_json;
Andrew Jefferyeab49292022-04-05 14:42:20 +0930901 DBusValueVariant v = std::vector<uint8_t>{};
Brad Bishopcd1868e2020-08-28 17:58:52 -0400902 EXPECT_FALSE(matchProbe(j, v));
903}