| Christopher Meis | 59ef1e7 | 2025-04-16 08:53:25 +0200 | [diff] [blame] | 1 | #include "entity_manager/utils.hpp" | 
| Brad Bishop | e45d8c7 | 2022-05-25 15:12:53 -0400 | [diff] [blame] | 2 | #include "utils.hpp" | 
| James Feist | 481c5d5 | 2019-08-13 14:40:40 -0700 | [diff] [blame] | 3 |  | 
| James Feist | 481c5d5 | 2019-08-13 14:40:40 -0700 | [diff] [blame] | 4 | #include <nlohmann/json.hpp> | 
| James Feist | 8c505da | 2020-05-28 10:06:33 -0700 | [diff] [blame] | 5 |  | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 6 | #include <string> | 
| James Feist | 481c5d5 | 2019-08-13 14:40:40 -0700 | [diff] [blame] | 7 | #include <variant> | 
 | 8 |  | 
 | 9 | #include "gtest/gtest.h" | 
 | 10 |  | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 11 | using namespace std::string_literals; | 
 | 12 |  | 
| James Feist | 481c5d5 | 2019-08-13 14:40:40 -0700 | [diff] [blame] | 13 | TEST(TemplateCharReplace, replaceOneInt) | 
 | 14 | { | 
 | 15 |     nlohmann::json j = {{"foo", "$bus"}}; | 
 | 16 |     auto it = j.begin(); | 
| Andrew Jeffery | 1983d2f | 2022-04-05 14:55:13 +0930 | [diff] [blame] | 17 |     DBusInterface data; | 
| James Feist | 481c5d5 | 2019-08-13 14:40:40 -0700 | [diff] [blame] | 18 |     data["BUS"] = 23; | 
 | 19 |  | 
| Christopher Meis | 59ef1e7 | 2025-04-16 08:53:25 +0200 | [diff] [blame] | 20 |     em_utils::templateCharReplace(it, data, 0); | 
| James Feist | 481c5d5 | 2019-08-13 14:40:40 -0700 | [diff] [blame] | 21 |  | 
 | 22 |     nlohmann::json expected = 23; | 
 | 23 |     EXPECT_EQ(expected, j["foo"]); | 
 | 24 | } | 
 | 25 |  | 
 | 26 | TEST(TemplateCharReplace, replaceOneStr) | 
 | 27 | { | 
 | 28 |     nlohmann::json j = {{"foo", "$TEST"}}; | 
 | 29 |     auto it = j.begin(); | 
| Andrew Jeffery | 1983d2f | 2022-04-05 14:55:13 +0930 | [diff] [blame] | 30 |     DBusInterface data; | 
| James Feist | 481c5d5 | 2019-08-13 14:40:40 -0700 | [diff] [blame] | 31 |     data["TEST"] = std::string("Test"); | 
 | 32 |  | 
| Christopher Meis | 59ef1e7 | 2025-04-16 08:53:25 +0200 | [diff] [blame] | 33 |     em_utils::templateCharReplace(it, data, 0); | 
| James Feist | 481c5d5 | 2019-08-13 14:40:40 -0700 | [diff] [blame] | 34 |  | 
 | 35 |     nlohmann::json expected = "Test"; | 
 | 36 |     EXPECT_EQ(expected, j["foo"]); | 
 | 37 | } | 
 | 38 |  | 
 | 39 | TEST(TemplateCharReplace, replaceSecondStr) | 
 | 40 | { | 
 | 41 |     nlohmann::json j = {{"foo", "the $TEST"}}; | 
 | 42 |     auto it = j.begin(); | 
| Andrew Jeffery | 1983d2f | 2022-04-05 14:55:13 +0930 | [diff] [blame] | 43 |     DBusInterface data; | 
| James Feist | 481c5d5 | 2019-08-13 14:40:40 -0700 | [diff] [blame] | 44 |     data["TEST"] = std::string("Test"); | 
 | 45 |  | 
| Christopher Meis | 59ef1e7 | 2025-04-16 08:53:25 +0200 | [diff] [blame] | 46 |     em_utils::templateCharReplace(it, data, 0); | 
| James Feist | 481c5d5 | 2019-08-13 14:40:40 -0700 | [diff] [blame] | 47 |  | 
 | 48 |     nlohmann::json expected = "the Test"; | 
 | 49 |     EXPECT_EQ(expected, j["foo"]); | 
 | 50 | } | 
 | 51 |  | 
| James Feist | 481c5d5 | 2019-08-13 14:40:40 -0700 | [diff] [blame] | 52 | TEST(TemplateCharReplace, replaceMiddleStr) | 
 | 53 | { | 
 | 54 |     nlohmann::json j = {{"foo", "the $TEST worked"}}; | 
 | 55 |     auto it = j.begin(); | 
| Andrew Jeffery | 1983d2f | 2022-04-05 14:55:13 +0930 | [diff] [blame] | 56 |     DBusInterface data; | 
| James Feist | 481c5d5 | 2019-08-13 14:40:40 -0700 | [diff] [blame] | 57 |     data["TEST"] = std::string("Test"); | 
 | 58 |  | 
| Christopher Meis | 59ef1e7 | 2025-04-16 08:53:25 +0200 | [diff] [blame] | 59 |     em_utils::templateCharReplace(it, data, 0); | 
| James Feist | 481c5d5 | 2019-08-13 14:40:40 -0700 | [diff] [blame] | 60 |  | 
 | 61 |     nlohmann::json expected = "the Test worked"; | 
 | 62 |     EXPECT_EQ(expected, j["foo"]); | 
 | 63 | } | 
| James Feist | 481c5d5 | 2019-08-13 14:40:40 -0700 | [diff] [blame] | 64 |  | 
 | 65 | TEST(TemplateCharReplace, replaceLastStr) | 
 | 66 | { | 
 | 67 |     nlohmann::json j = {{"foo", "the Test $TEST"}}; | 
 | 68 |     auto it = j.begin(); | 
| Andrew Jeffery | 1983d2f | 2022-04-05 14:55:13 +0930 | [diff] [blame] | 69 |     DBusInterface data; | 
| James Feist | 481c5d5 | 2019-08-13 14:40:40 -0700 | [diff] [blame] | 70 |     data["TEST"] = 23; | 
 | 71 |  | 
| Christopher Meis | 59ef1e7 | 2025-04-16 08:53:25 +0200 | [diff] [blame] | 72 |     em_utils::templateCharReplace(it, data, 0); | 
| James Feist | 481c5d5 | 2019-08-13 14:40:40 -0700 | [diff] [blame] | 73 |  | 
 | 74 |     nlohmann::json expected = "the Test 23"; | 
 | 75 |     EXPECT_EQ(expected, j["foo"]); | 
 | 76 | } | 
 | 77 |  | 
 | 78 | TEST(TemplateCharReplace, increment) | 
 | 79 | { | 
 | 80 |     nlohmann::json j = {{"foo", "3 plus 1 equals $TEST + 1"}}; | 
 | 81 |     auto it = j.begin(); | 
| Andrew Jeffery | 1983d2f | 2022-04-05 14:55:13 +0930 | [diff] [blame] | 82 |     DBusInterface data; | 
| James Feist | 481c5d5 | 2019-08-13 14:40:40 -0700 | [diff] [blame] | 83 |     data["TEST"] = 3; | 
 | 84 |  | 
| Christopher Meis | 59ef1e7 | 2025-04-16 08:53:25 +0200 | [diff] [blame] | 85 |     em_utils::templateCharReplace(it, data, 0); | 
| James Feist | 481c5d5 | 2019-08-13 14:40:40 -0700 | [diff] [blame] | 86 |  | 
 | 87 |     nlohmann::json expected = "3 plus 1 equals 4"; | 
 | 88 |     EXPECT_EQ(expected, j["foo"]); | 
 | 89 | } | 
 | 90 |  | 
 | 91 | TEST(TemplateCharReplace, decrement) | 
 | 92 | { | 
 | 93 |     nlohmann::json j = {{"foo", "3 minus 1 equals $TEST - 1 !"}}; | 
 | 94 |     auto it = j.begin(); | 
| Andrew Jeffery | 1983d2f | 2022-04-05 14:55:13 +0930 | [diff] [blame] | 95 |     DBusInterface data; | 
| James Feist | 481c5d5 | 2019-08-13 14:40:40 -0700 | [diff] [blame] | 96 |     data["TEST"] = 3; | 
 | 97 |  | 
| Christopher Meis | 59ef1e7 | 2025-04-16 08:53:25 +0200 | [diff] [blame] | 98 |     em_utils::templateCharReplace(it, data, 0); | 
| James Feist | 481c5d5 | 2019-08-13 14:40:40 -0700 | [diff] [blame] | 99 |  | 
 | 100 |     nlohmann::json expected = "3 minus 1 equals 2 !"; | 
 | 101 |     EXPECT_EQ(expected, j["foo"]); | 
 | 102 | } | 
 | 103 |  | 
 | 104 | TEST(TemplateCharReplace, modulus) | 
 | 105 | { | 
 | 106 |     nlohmann::json j = {{"foo", "3 mod 2 equals $TEST % 2"}}; | 
 | 107 |     auto it = j.begin(); | 
| Andrew Jeffery | 1983d2f | 2022-04-05 14:55:13 +0930 | [diff] [blame] | 108 |     DBusInterface data; | 
| James Feist | 481c5d5 | 2019-08-13 14:40:40 -0700 | [diff] [blame] | 109 |     data["TEST"] = 3; | 
 | 110 |  | 
| Christopher Meis | 59ef1e7 | 2025-04-16 08:53:25 +0200 | [diff] [blame] | 111 |     em_utils::templateCharReplace(it, data, 0); | 
| James Feist | 481c5d5 | 2019-08-13 14:40:40 -0700 | [diff] [blame] | 112 |  | 
 | 113 |     nlohmann::json expected = "3 mod 2 equals 1"; | 
 | 114 |     EXPECT_EQ(expected, j["foo"]); | 
 | 115 | } | 
 | 116 |  | 
 | 117 | TEST(TemplateCharReplace, multiply) | 
 | 118 | { | 
 | 119 |     nlohmann::json j = {{"foo", "3 * 2 equals $TEST * 2"}}; | 
 | 120 |     auto it = j.begin(); | 
| Andrew Jeffery | 1983d2f | 2022-04-05 14:55:13 +0930 | [diff] [blame] | 121 |     DBusInterface data; | 
| James Feist | 481c5d5 | 2019-08-13 14:40:40 -0700 | [diff] [blame] | 122 |     data["TEST"] = 3; | 
 | 123 |  | 
| Christopher Meis | 59ef1e7 | 2025-04-16 08:53:25 +0200 | [diff] [blame] | 124 |     em_utils::templateCharReplace(it, data, 0); | 
| James Feist | 481c5d5 | 2019-08-13 14:40:40 -0700 | [diff] [blame] | 125 |  | 
 | 126 |     nlohmann::json expected = "3 * 2 equals 6"; | 
 | 127 |     EXPECT_EQ(expected, j["foo"]); | 
 | 128 | } | 
 | 129 |  | 
 | 130 | TEST(TemplateCharReplace, divide) | 
 | 131 | { | 
 | 132 |     nlohmann::json j = {{"foo", "4 / 2 equals $TEST / 2"}}; | 
 | 133 |     auto it = j.begin(); | 
| Andrew Jeffery | 1983d2f | 2022-04-05 14:55:13 +0930 | [diff] [blame] | 134 |     DBusInterface data; | 
| James Feist | 481c5d5 | 2019-08-13 14:40:40 -0700 | [diff] [blame] | 135 |     data["TEST"] = 4; | 
 | 136 |  | 
| Christopher Meis | 59ef1e7 | 2025-04-16 08:53:25 +0200 | [diff] [blame] | 137 |     em_utils::templateCharReplace(it, data, 0); | 
| James Feist | 481c5d5 | 2019-08-13 14:40:40 -0700 | [diff] [blame] | 138 |  | 
 | 139 |     nlohmann::json expected = "4 / 2 equals 2"; | 
 | 140 |     EXPECT_EQ(expected, j["foo"]); | 
| James Feist | 8c20feb | 2019-08-14 15:10:11 -0700 | [diff] [blame] | 141 | } | 
 | 142 |  | 
 | 143 | TEST(TemplateCharReplace, multiMath) | 
 | 144 | { | 
 | 145 |     nlohmann::json j = {{"foo", "4 * 2 % 6 equals $TEST * 2 % 6"}}; | 
 | 146 |     auto it = j.begin(); | 
| Andrew Jeffery | 1983d2f | 2022-04-05 14:55:13 +0930 | [diff] [blame] | 147 |     DBusInterface data; | 
| James Feist | 8c20feb | 2019-08-14 15:10:11 -0700 | [diff] [blame] | 148 |     data["TEST"] = 4; | 
 | 149 |  | 
| Christopher Meis | 59ef1e7 | 2025-04-16 08:53:25 +0200 | [diff] [blame] | 150 |     em_utils::templateCharReplace(it, data, 0); | 
| James Feist | 8c20feb | 2019-08-14 15:10:11 -0700 | [diff] [blame] | 151 |  | 
 | 152 |     nlohmann::json expected = "4 * 2 % 6 equals 2"; | 
 | 153 |     EXPECT_EQ(expected, j["foo"]); | 
 | 154 | } | 
 | 155 |  | 
 | 156 | TEST(TemplateCharReplace, twoReplacements) | 
 | 157 | { | 
 | 158 |     nlohmann::json j = {{"foo", "$FOO $BAR"}}; | 
 | 159 |     auto it = j.begin(); | 
| Andrew Jeffery | 1983d2f | 2022-04-05 14:55:13 +0930 | [diff] [blame] | 160 |     DBusInterface data; | 
| James Feist | 8c20feb | 2019-08-14 15:10:11 -0700 | [diff] [blame] | 161 |     data["FOO"] = std::string("foo"); | 
 | 162 |     data["BAR"] = std::string("bar"); | 
 | 163 |  | 
| Christopher Meis | 59ef1e7 | 2025-04-16 08:53:25 +0200 | [diff] [blame] | 164 |     em_utils::templateCharReplace(it, data, 0); | 
| James Feist | 8c20feb | 2019-08-14 15:10:11 -0700 | [diff] [blame] | 165 |  | 
 | 166 |     nlohmann::json expected = "foo bar"; | 
 | 167 |     EXPECT_EQ(expected, j["foo"]); | 
 | 168 | } | 
 | 169 |  | 
 | 170 | TEST(TemplateCharReplace, twoReplacementsWithMath) | 
 | 171 | { | 
 | 172 |     nlohmann::json j = {{"foo", "4 / 2 equals $TEST / 2 $BAR"}}; | 
 | 173 |     auto it = j.begin(); | 
| Andrew Jeffery | 1983d2f | 2022-04-05 14:55:13 +0930 | [diff] [blame] | 174 |     DBusInterface data; | 
| James Feist | 8c20feb | 2019-08-14 15:10:11 -0700 | [diff] [blame] | 175 |     data["TEST"] = 4; | 
 | 176 |     data["BAR"] = std::string("bar"); | 
 | 177 |  | 
| Christopher Meis | 59ef1e7 | 2025-04-16 08:53:25 +0200 | [diff] [blame] | 178 |     em_utils::templateCharReplace(it, data, 0); | 
| James Feist | 8c20feb | 2019-08-14 15:10:11 -0700 | [diff] [blame] | 179 |  | 
 | 180 |     nlohmann::json expected = "4 / 2 equals 2 bar"; | 
| Zhikui Ren | a0d1b3f | 2021-10-05 16:21:56 -0700 | [diff] [blame] | 181 | } | 
 | 182 |  | 
 | 183 | TEST(TemplateCharReplace, twoReplacementsWithMath2) | 
 | 184 | { | 
 | 185 |     nlohmann::json j = {{"foo", "4 / 2 equals $ADDRESS / 2 $BAR"}}; | 
 | 186 |     auto it = j.begin(); | 
| Andrew Jeffery | 1983d2f | 2022-04-05 14:55:13 +0930 | [diff] [blame] | 187 |     DBusInterface data; | 
| Zhikui Ren | a0d1b3f | 2021-10-05 16:21:56 -0700 | [diff] [blame] | 188 |     data["ADDRESS"] = 4; | 
 | 189 |     data["BAR"] = std::string("bar"); | 
 | 190 |  | 
| Christopher Meis | 59ef1e7 | 2025-04-16 08:53:25 +0200 | [diff] [blame] | 191 |     em_utils::templateCharReplace(it, data, 0); | 
| Zhikui Ren | a0d1b3f | 2021-10-05 16:21:56 -0700 | [diff] [blame] | 192 |  | 
 | 193 |     nlohmann::json expected = "4 / 2 equals 2 bar"; | 
| James Feist | 8c20feb | 2019-08-14 15:10:11 -0700 | [diff] [blame] | 194 |     EXPECT_EQ(expected, j["foo"]); | 
| James Feist | b0097d4 | 2019-08-15 09:24:13 -0700 | [diff] [blame] | 195 | } | 
 | 196 |  | 
 | 197 | TEST(TemplateCharReplace, hexAndWrongCase) | 
 | 198 | { | 
 | 199 |     nlohmann::json j = {{"Address", "0x54"}, | 
 | 200 |                         {"Bus", 15}, | 
 | 201 |                         {"Name", "$bus sensor 0"}, | 
 | 202 |                         {"Type", "SomeType"}}; | 
 | 203 |  | 
| Andrew Jeffery | 1983d2f | 2022-04-05 14:55:13 +0930 | [diff] [blame] | 204 |     DBusInterface data; | 
| James Feist | b0097d4 | 2019-08-15 09:24:13 -0700 | [diff] [blame] | 205 |     data["BUS"] = 15; | 
 | 206 |  | 
 | 207 |     for (auto it = j.begin(); it != j.end(); it++) | 
 | 208 |     { | 
| Christopher Meis | 59ef1e7 | 2025-04-16 08:53:25 +0200 | [diff] [blame] | 209 |         em_utils::templateCharReplace(it, data, 0); | 
| James Feist | b0097d4 | 2019-08-15 09:24:13 -0700 | [diff] [blame] | 210 |     } | 
 | 211 |     nlohmann::json expected = {{"Address", 84}, | 
 | 212 |                                {"Bus", 15}, | 
 | 213 |                                {"Name", "15 sensor 0"}, | 
 | 214 |                                {"Type", "SomeType"}}; | 
 | 215 |     EXPECT_EQ(expected, j); | 
 | 216 | } | 
 | 217 |  | 
 | 218 | TEST(TemplateCharReplace, replaceSecondAsInt) | 
 | 219 | { | 
 | 220 |     nlohmann::json j = {{"foo", "twelve is $TEST"}}; | 
 | 221 |     auto it = j.begin(); | 
| Andrew Jeffery | 1983d2f | 2022-04-05 14:55:13 +0930 | [diff] [blame] | 222 |     DBusInterface data; | 
| James Feist | b0097d4 | 2019-08-15 09:24:13 -0700 | [diff] [blame] | 223 |     data["test"] = 12; | 
 | 224 |  | 
| Christopher Meis | 59ef1e7 | 2025-04-16 08:53:25 +0200 | [diff] [blame] | 225 |     em_utils::templateCharReplace(it, data, 0); | 
| James Feist | b0097d4 | 2019-08-15 09:24:13 -0700 | [diff] [blame] | 226 |  | 
 | 227 |     nlohmann::json expected = "twelve is 12"; | 
 | 228 |     EXPECT_EQ(expected, j["foo"]); | 
 | 229 | } | 
| James Feist | c296c80 | 2019-08-28 09:26:47 -0700 | [diff] [blame] | 230 |  | 
 | 231 | TEST(TemplateCharReplace, singleHex) | 
 | 232 | { | 
 | 233 |     nlohmann::json j = {{"foo", "0x54"}}; | 
 | 234 |     auto it = j.begin(); | 
| Andrew Jeffery | 1983d2f | 2022-04-05 14:55:13 +0930 | [diff] [blame] | 235 |     DBusInterface data; | 
| James Feist | c296c80 | 2019-08-28 09:26:47 -0700 | [diff] [blame] | 236 |  | 
| Christopher Meis | 59ef1e7 | 2025-04-16 08:53:25 +0200 | [diff] [blame] | 237 |     em_utils::templateCharReplace(it, data, 0); | 
| James Feist | c296c80 | 2019-08-28 09:26:47 -0700 | [diff] [blame] | 238 |  | 
 | 239 |     nlohmann::json expected = 84; | 
 | 240 |     EXPECT_EQ(expected, j["foo"]); | 
 | 241 | } | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 242 |  | 
| Chau Ly | 7962944 | 2025-08-20 10:27:20 +0000 | [diff] [blame] | 243 | TEST(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 |  | 
 | 260 | TEST(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 Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 271 | TEST(MatchProbe, stringEqString) | 
 | 272 | { | 
 | 273 |     nlohmann::json j = R"("foo")"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 274 |     DBusValueVariant v = "foo"s; | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 275 |     EXPECT_TRUE(matchProbe(j, v)); | 
 | 276 | } | 
 | 277 |  | 
 | 278 | TEST(MatchProbe, stringRegexEqString) | 
 | 279 | { | 
 | 280 |     nlohmann::json j = R"("foo*")"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 281 |     DBusValueVariant v = "foobar"s; | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 282 |     EXPECT_TRUE(matchProbe(j, v)); | 
 | 283 | } | 
 | 284 |  | 
 | 285 | TEST(MatchProbe, stringNeqString) | 
 | 286 | { | 
 | 287 |     nlohmann::json j = R"("foobar")"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 288 |     DBusValueVariant v = "foo"s; | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 289 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 290 | } | 
 | 291 |  | 
 | 292 | TEST(MatchProbe, stringRegexError) | 
 | 293 | { | 
 | 294 |     nlohmann::json j = R"("foo[")"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 295 |     DBusValueVariant v = "foobar"s; | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 296 |     EXPECT_FALSE(matchProbe(j, v)); | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 297 | } | 
 | 298 |  | 
| Patrick Rudolph | 1c39d7b | 2023-09-21 15:50:20 +0200 | [diff] [blame] | 299 | TEST(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 Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 308 | TEST(MatchProbe, stringZeroNeqFalse) | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 309 | { | 
 | 310 |     nlohmann::json j = R"("0")"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 311 |     DBusValueVariant v = false; | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 312 |     EXPECT_FALSE(matchProbe(j, v)); | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 313 | } | 
 | 314 |  | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 315 | TEST(MatchProbe, stringOneNeqTrue) | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 316 | { | 
 | 317 |     nlohmann::json j = R"("1")"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 318 |     DBusValueVariant v = true; | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 319 |     EXPECT_FALSE(matchProbe(j, v)); | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 320 | } | 
 | 321 |  | 
 | 322 | TEST(MatchProbe, stringElevenNeqTrue) | 
 | 323 | { | 
 | 324 |     nlohmann::json j = R"("11")"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 325 |     DBusValueVariant v = true; | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 326 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 327 | } | 
 | 328 |  | 
 | 329 | TEST(MatchProbe, stringFalseNeqFalse) | 
 | 330 | { | 
 | 331 |     nlohmann::json j = R"("false")"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 332 |     DBusValueVariant v = false; | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 333 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 334 | } | 
 | 335 |  | 
 | 336 | TEST(MatchProbe, stringTrueNeqTrue) | 
 | 337 | { | 
 | 338 |     nlohmann::json j = R"("true")"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 339 |     DBusValueVariant v = true; | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 340 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 341 | } | 
 | 342 |  | 
 | 343 | TEST(MatchProbe, stringFalseNeqTrue) | 
 | 344 | { | 
 | 345 |     nlohmann::json j = R"("false")"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 346 |     DBusValueVariant v = true; | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 347 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 348 | } | 
 | 349 |  | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 350 | TEST(MatchProbe, stringNeqUint8) | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 351 | { | 
 | 352 |     nlohmann::json j = R"("255")"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 353 |     DBusValueVariant v = uint8_t(255); | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 354 |     EXPECT_FALSE(matchProbe(j, v)); | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 355 | } | 
 | 356 |  | 
 | 357 | TEST(MatchProbe, stringNeqUint8Overflow) | 
 | 358 | { | 
 | 359 |     nlohmann::json j = R"("65535")"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 360 |     DBusValueVariant v = uint8_t(255); | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 361 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 362 | } | 
 | 363 |  | 
 | 364 | TEST(MatchProbe, stringFalseNeqUint8Zero) | 
 | 365 | { | 
 | 366 |     nlohmann::json j = R"("false")"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 367 |     DBusValueVariant v = uint8_t(0); | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 368 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 369 | } | 
 | 370 |  | 
 | 371 | TEST(MatchProbe, stringTrueNeqUint8Zero) | 
 | 372 | { | 
 | 373 |     nlohmann::json j = R"("true")"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 374 |     DBusValueVariant v = uint8_t(1); | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 375 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 376 | } | 
 | 377 |  | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 378 | TEST(MatchProbe, stringNeqUint32) | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 379 | { | 
 | 380 |     nlohmann::json j = R"("11")"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 381 |     DBusValueVariant v = uint32_t(11); | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 382 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 383 | } | 
 | 384 |  | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 385 | TEST(MatchProbe, stringNeqInt32) | 
 | 386 | { | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 387 |     nlohmann::json j = R"("-11")"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 388 |     DBusValueVariant v = int32_t(-11); | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 389 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 390 | } | 
 | 391 |  | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 392 | TEST(MatchProbe, stringRegexNeqInt32) | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 393 | { | 
 | 394 |     nlohmann::json j = R"("1*4")"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 395 |     DBusValueVariant v = int32_t(124); | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 396 |     EXPECT_FALSE(matchProbe(j, v)); | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 397 | } | 
 | 398 |  | 
 | 399 | TEST(MatchProbe, stringNeqUint64) | 
 | 400 | { | 
 | 401 |     nlohmann::json j = R"("foo")"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 402 |     DBusValueVariant v = uint64_t(65535); | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 403 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 404 | } | 
 | 405 |  | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 406 | TEST(MatchProbe, stringNeqDouble) | 
 | 407 | { | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 408 |     nlohmann::json j = R"("123.4")"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 409 |     DBusValueVariant v = double(123.4); | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 410 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 411 | } | 
 | 412 |  | 
 | 413 | TEST(MatchProbe, stringNeqEmpty) | 
 | 414 | { | 
 | 415 |     nlohmann::json j = R"("-123.4")"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 416 |     DBusValueVariant v; | 
| Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 417 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 418 | } | 
| Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 419 |  | 
| Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 420 | TEST(MatchProbe, stringNeqArray) | 
 | 421 | { | 
 | 422 |     nlohmann::json j = R"("-123.4")"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 423 |     DBusValueVariant v = std::vector<uint8_t>{1, 2}; | 
| Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 424 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 425 | } | 
 | 426 |  | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 427 | TEST(MatchProbe, boolNeqString) | 
| Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 428 | { | 
 | 429 |     nlohmann::json j = R"(false)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 430 |     DBusValueVariant v = "false"s; | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 431 |     EXPECT_FALSE(matchProbe(j, v)); | 
| Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 432 | } | 
 | 433 |  | 
 | 434 | TEST(MatchProbe, trueEqTrue) | 
 | 435 | { | 
 | 436 |     nlohmann::json j = R"(true)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 437 |     DBusValueVariant v = true; | 
| Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 438 |     EXPECT_TRUE(matchProbe(j, v)); | 
 | 439 | } | 
 | 440 |  | 
 | 441 | TEST(MatchProbe, falseEqFalse) | 
 | 442 | { | 
 | 443 |     nlohmann::json j = R"(false)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 444 |     DBusValueVariant v = false; | 
| Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 445 |     EXPECT_TRUE(matchProbe(j, v)); | 
 | 446 | } | 
 | 447 |  | 
 | 448 | TEST(MatchProbe, trueNeqFalse) | 
 | 449 | { | 
 | 450 |     nlohmann::json j = R"(true)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 451 |     DBusValueVariant v = false; | 
| Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 452 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 453 | } | 
 | 454 |  | 
 | 455 | TEST(MatchProbe, trueNeqInt32Zero) | 
 | 456 | { | 
 | 457 |     nlohmann::json j = R"(true)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 458 |     DBusValueVariant v = int32_t(0); | 
| Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 459 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 460 | } | 
 | 461 |  | 
 | 462 | TEST(MatchProbe, trueNeqInt32NegativeOne) | 
 | 463 | { | 
 | 464 |     nlohmann::json j = R"(true)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 465 |     DBusValueVariant v = int32_t(-1); | 
| Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 466 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 467 | } | 
 | 468 |  | 
 | 469 | TEST(MatchProbe, falseNeqUint32One) | 
 | 470 | { | 
 | 471 |     nlohmann::json j = R"(false)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 472 |     DBusValueVariant v = uint32_t(1); | 
| Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 473 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 474 | } | 
 | 475 |  | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 476 | TEST(MatchProbe, falseNeqUint32Zero) | 
| Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 477 | { | 
 | 478 |     nlohmann::json j = R"(false)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 479 |     DBusValueVariant v = uint32_t(0); | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 480 |     EXPECT_FALSE(matchProbe(j, v)); | 
| Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 481 | } | 
 | 482 |  | 
 | 483 | TEST(MatchProbe, trueNeqDoubleNegativeOne) | 
 | 484 | { | 
 | 485 |     nlohmann::json j = R"(true)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 486 |     DBusValueVariant v = double(-1.1); | 
| Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 487 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 488 | } | 
 | 489 |  | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 490 | TEST(MatchProbe, trueNeqDoubleOne) | 
| Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 491 | { | 
 | 492 |     nlohmann::json j = R"(true)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 493 |     DBusValueVariant v = double(1.0); | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 494 |     EXPECT_FALSE(matchProbe(j, v)); | 
| Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 495 | } | 
 | 496 |  | 
 | 497 | TEST(MatchProbe, falseNeqDoubleOne) | 
 | 498 | { | 
 | 499 |     nlohmann::json j = R"(false)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 500 |     DBusValueVariant v = double(1.0); | 
| Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 501 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 502 | } | 
 | 503 |  | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 504 | TEST(MatchProbe, falseNeqDoubleZero) | 
| Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 505 | { | 
 | 506 |     nlohmann::json j = R"(false)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 507 |     DBusValueVariant v = double(0.0); | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 508 |     EXPECT_FALSE(matchProbe(j, v)); | 
| Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 509 | } | 
 | 510 |  | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 511 | TEST(MatchProbe, falseNeqEmpty) | 
| Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 512 | { | 
 | 513 |     nlohmann::json j = R"(false)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 514 |     DBusValueVariant v; | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 515 |     EXPECT_FALSE(matchProbe(j, v)); | 
| Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 516 | } | 
 | 517 |  | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 518 | TEST(MatchProbe, trueNeqEmpty) | 
| Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 519 | { | 
 | 520 |     nlohmann::json j = R"(true)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 521 |     DBusValueVariant v; | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 522 |     EXPECT_FALSE(matchProbe(j, v)); | 
| Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 523 | } | 
| Brad Bishop | c2af531 | 2020-08-28 10:39:49 -0400 | [diff] [blame] | 524 |  | 
| Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 525 | TEST(MatchProbe, trueNeqArray) | 
 | 526 | { | 
 | 527 |     nlohmann::json j = R"(true)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 528 |     DBusValueVariant v = std::vector<uint8_t>{1, 2}; | 
| Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 529 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 530 | } | 
 | 531 |  | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 532 | TEST(MatchProbe, uintNeqString) | 
| Brad Bishop | c2af531 | 2020-08-28 10:39:49 -0400 | [diff] [blame] | 533 | { | 
 | 534 |     nlohmann::json j = R"(11)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 535 |     DBusValueVariant v = "11"s; | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 536 |     EXPECT_FALSE(matchProbe(j, v)); | 
| Brad Bishop | c2af531 | 2020-08-28 10:39:49 -0400 | [diff] [blame] | 537 | } | 
 | 538 |  | 
 | 539 | TEST(MatchProbe, uintNeqTrue) | 
 | 540 | { | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 541 |     nlohmann::json j = R"(1)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 542 |     DBusValueVariant v = true; | 
| Brad Bishop | c2af531 | 2020-08-28 10:39:49 -0400 | [diff] [blame] | 543 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 544 | } | 
 | 545 |  | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 546 | TEST(MatchProbe, uintNeqFalse) | 
 | 547 | { | 
 | 548 |     nlohmann::json j = R"(0)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 549 |     DBusValueVariant v = false; | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 550 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 551 | } | 
 | 552 |  | 
| Brad Bishop | c2af531 | 2020-08-28 10:39:49 -0400 | [diff] [blame] | 553 | TEST(MatchProbe, uintEqUint8) | 
 | 554 | { | 
 | 555 |     nlohmann::json j = R"(11)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 556 |     DBusValueVariant v = uint8_t(11); | 
| Brad Bishop | c2af531 | 2020-08-28 10:39:49 -0400 | [diff] [blame] | 557 |     EXPECT_TRUE(matchProbe(j, v)); | 
 | 558 | } | 
 | 559 |  | 
 | 560 | TEST(MatchProbe, uintNeqUint8) | 
 | 561 | { | 
 | 562 |     nlohmann::json j = R"(11)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 563 |     DBusValueVariant v = uint8_t(12); | 
| Brad Bishop | c2af531 | 2020-08-28 10:39:49 -0400 | [diff] [blame] | 564 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 565 | } | 
 | 566 |  | 
 | 567 | TEST(MatchProbe, uintNeqUint8Overflow) | 
 | 568 | { | 
 | 569 |     nlohmann::json j = R"(65535)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 570 |     DBusValueVariant v = uint8_t(255); | 
| Brad Bishop | c2af531 | 2020-08-28 10:39:49 -0400 | [diff] [blame] | 571 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 572 | } | 
 | 573 |  | 
 | 574 | TEST(MatchProbe, uintEqInt8) | 
 | 575 | { | 
 | 576 |     nlohmann::json j = R"(11)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 577 |     DBusValueVariant v = int8_t(11); | 
| Brad Bishop | c2af531 | 2020-08-28 10:39:49 -0400 | [diff] [blame] | 578 |     EXPECT_TRUE(matchProbe(j, v)); | 
 | 579 | } | 
 | 580 |  | 
 | 581 | TEST(MatchProbe, uintEqDouble) | 
 | 582 | { | 
 | 583 |     nlohmann::json j = R"(11)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 584 |     DBusValueVariant v = double(11.0); | 
| Brad Bishop | c2af531 | 2020-08-28 10:39:49 -0400 | [diff] [blame] | 585 |     EXPECT_TRUE(matchProbe(j, v)); | 
 | 586 | } | 
 | 587 |  | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 588 | TEST(MatchProbe, uintNeqDouble) | 
| Brad Bishop | c2af531 | 2020-08-28 10:39:49 -0400 | [diff] [blame] | 589 | { | 
 | 590 |     nlohmann::json j = R"(11)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 591 |     DBusValueVariant v = double(11.7); | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 592 |     EXPECT_FALSE(matchProbe(j, v)); | 
| Brad Bishop | c2af531 | 2020-08-28 10:39:49 -0400 | [diff] [blame] | 593 | } | 
 | 594 |  | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 595 | TEST(MatchProbe, uintNeqEmpty) | 
| Brad Bishop | c2af531 | 2020-08-28 10:39:49 -0400 | [diff] [blame] | 596 | { | 
 | 597 |     nlohmann::json j = R"(11)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 598 |     DBusValueVariant v; | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 599 |     EXPECT_FALSE(matchProbe(j, v)); | 
| Brad Bishop | c2af531 | 2020-08-28 10:39:49 -0400 | [diff] [blame] | 600 | } | 
| Brad Bishop | 667e050 | 2020-08-28 10:41:40 -0400 | [diff] [blame] | 601 |  | 
| Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 602 | TEST(MatchProbe, uintNeqArray) | 
 | 603 | { | 
 | 604 |     nlohmann::json j = R"(11)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 605 |     DBusValueVariant v = std::vector<uint8_t>{11}; | 
| Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 606 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 607 | } | 
 | 608 |  | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 609 | TEST(MatchProbe, intNeqString) | 
| Brad Bishop | 667e050 | 2020-08-28 10:41:40 -0400 | [diff] [blame] | 610 | { | 
 | 611 |     nlohmann::json j = R"(-11)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 612 |     DBusValueVariant v = "-11"s; | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 613 |     EXPECT_FALSE(matchProbe(j, v)); | 
| Brad Bishop | 667e050 | 2020-08-28 10:41:40 -0400 | [diff] [blame] | 614 | } | 
 | 615 |  | 
 | 616 | TEST(MatchProbe, intNeqTrue) | 
 | 617 | { | 
 | 618 |     nlohmann::json j = R"(-1)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 619 |     DBusValueVariant v = true; | 
| Brad Bishop | 667e050 | 2020-08-28 10:41:40 -0400 | [diff] [blame] | 620 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 621 | } | 
 | 622 |  | 
 | 623 | TEST(MatchProbe, intNeqUint8) | 
 | 624 | { | 
 | 625 |     nlohmann::json j = R"(-11)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 626 |     DBusValueVariant v = uint8_t(11); | 
| Brad Bishop | 667e050 | 2020-08-28 10:41:40 -0400 | [diff] [blame] | 627 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 628 | } | 
 | 629 |  | 
 | 630 | TEST(MatchProbe, intEqInt8) | 
 | 631 | { | 
 | 632 |     nlohmann::json j = R"(-11)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 633 |     DBusValueVariant v = int8_t(-11); | 
| Brad Bishop | 667e050 | 2020-08-28 10:41:40 -0400 | [diff] [blame] | 634 |     EXPECT_TRUE(matchProbe(j, v)); | 
 | 635 | } | 
 | 636 |  | 
 | 637 | TEST(MatchProbe, intNeqDouble) | 
 | 638 | { | 
 | 639 |     nlohmann::json j = R"(-124)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 640 |     DBusValueVariant v = double(-123.0); | 
| Brad Bishop | 667e050 | 2020-08-28 10:41:40 -0400 | [diff] [blame] | 641 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 642 | } | 
 | 643 |  | 
 | 644 | TEST(MatchProbe, intEqDouble) | 
 | 645 | { | 
 | 646 |     nlohmann::json j = R"(-11)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 647 |     DBusValueVariant v = double(-11.0); | 
| Brad Bishop | 667e050 | 2020-08-28 10:41:40 -0400 | [diff] [blame] | 648 |     EXPECT_TRUE(matchProbe(j, v)); | 
 | 649 | } | 
 | 650 |  | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 651 | TEST(MatchProbe, intNeqDoubleRound) | 
| Brad Bishop | 667e050 | 2020-08-28 10:41:40 -0400 | [diff] [blame] | 652 | { | 
 | 653 |     nlohmann::json j = R"(-11)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 654 |     DBusValueVariant v = double(-11.7); | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 655 |     EXPECT_FALSE(matchProbe(j, v)); | 
| Brad Bishop | 667e050 | 2020-08-28 10:41:40 -0400 | [diff] [blame] | 656 | } | 
 | 657 |  | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 658 | TEST(MatchProbe, intNeqEmpty) | 
| Brad Bishop | 667e050 | 2020-08-28 10:41:40 -0400 | [diff] [blame] | 659 | { | 
 | 660 |     nlohmann::json j = R"(-11)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 661 |     DBusValueVariant v; | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 662 |     EXPECT_FALSE(matchProbe(j, v)); | 
| Brad Bishop | 667e050 | 2020-08-28 10:41:40 -0400 | [diff] [blame] | 663 | } | 
| Brad Bishop | 3bd8e8d | 2020-08-28 10:42:27 -0400 | [diff] [blame] | 664 |  | 
| Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 665 | TEST(MatchProbe, intNeqArray) | 
 | 666 | { | 
 | 667 |     nlohmann::json j = R"(-11)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 668 |     DBusValueVariant v = std::vector<uint8_t>{11}; | 
| Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 669 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 670 | } | 
 | 671 |  | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 672 | TEST(MatchProbe, doubleNeqString) | 
| Brad Bishop | 3bd8e8d | 2020-08-28 10:42:27 -0400 | [diff] [blame] | 673 | { | 
 | 674 |     nlohmann::json j = R"(0.0)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 675 |     DBusValueVariant v = "0.0"s; | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 676 |     EXPECT_FALSE(matchProbe(j, v)); | 
| Brad Bishop | 3bd8e8d | 2020-08-28 10:42:27 -0400 | [diff] [blame] | 677 | } | 
 | 678 |  | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 679 | TEST(MatchProbe, doubleNeqFalse) | 
| Brad Bishop | 3bd8e8d | 2020-08-28 10:42:27 -0400 | [diff] [blame] | 680 | { | 
 | 681 |     nlohmann::json j = R"(0.0)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 682 |     DBusValueVariant v = false; | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 683 |     EXPECT_FALSE(matchProbe(j, v)); | 
| Brad Bishop | 3bd8e8d | 2020-08-28 10:42:27 -0400 | [diff] [blame] | 684 | } | 
 | 685 |  | 
 | 686 | TEST(MatchProbe, doubleNeqTrue) | 
 | 687 | { | 
| Brad Bishop | 3bd8e8d | 2020-08-28 10:42:27 -0400 | [diff] [blame] | 688 |     nlohmann::json j = R"(1.0)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 689 |     DBusValueVariant v = true; | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 690 |     EXPECT_FALSE(matchProbe(j, v)); | 
| Brad Bishop | 3bd8e8d | 2020-08-28 10:42:27 -0400 | [diff] [blame] | 691 | } | 
 | 692 |  | 
 | 693 | TEST(MatchProbe, doubleEqInt32) | 
 | 694 | { | 
 | 695 |     nlohmann::json j = R"(-124.0)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 696 |     DBusValueVariant v = int32_t(-124); | 
| Brad Bishop | 3bd8e8d | 2020-08-28 10:42:27 -0400 | [diff] [blame] | 697 |     EXPECT_TRUE(matchProbe(j, v)); | 
 | 698 | } | 
 | 699 |  | 
 | 700 | TEST(MatchProbe, doubleNeqInt32) | 
 | 701 | { | 
 | 702 |     nlohmann::json j = R"(-124.0)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 703 |     DBusValueVariant v = int32_t(-123); | 
| Brad Bishop | 3bd8e8d | 2020-08-28 10:42:27 -0400 | [diff] [blame] | 704 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 705 | } | 
 | 706 |  | 
 | 707 | TEST(MatchProbe, doubleRoundNeqInt) | 
 | 708 | { | 
 | 709 |     nlohmann::json j = R"(124.7)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 710 |     DBusValueVariant v = int32_t(124); | 
| Brad Bishop | 3bd8e8d | 2020-08-28 10:42:27 -0400 | [diff] [blame] | 711 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 712 | } | 
 | 713 | TEST(MatchProbe, doubleEqDouble) | 
 | 714 | { | 
 | 715 |     nlohmann::json j = R"(-124.2)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 716 |     DBusValueVariant v = double(-124.2); | 
| Brad Bishop | 3bd8e8d | 2020-08-28 10:42:27 -0400 | [diff] [blame] | 717 |     EXPECT_TRUE(matchProbe(j, v)); | 
 | 718 | } | 
 | 719 |  | 
 | 720 | TEST(MatchProbe, doubleNeqDouble) | 
 | 721 | { | 
 | 722 |     nlohmann::json j = R"(-124.3)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 723 |     DBusValueVariant v = double(-124.2); | 
| Brad Bishop | 3bd8e8d | 2020-08-28 10:42:27 -0400 | [diff] [blame] | 724 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 725 | } | 
 | 726 |  | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 727 | TEST(MatchProbe, doubleNeqEmpty) | 
| Brad Bishop | 3bd8e8d | 2020-08-28 10:42:27 -0400 | [diff] [blame] | 728 | { | 
 | 729 |     nlohmann::json j = R"(-11.0)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 730 |     DBusValueVariant v; | 
| Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 731 |     EXPECT_FALSE(matchProbe(j, v)); | 
| Brad Bishop | 3bd8e8d | 2020-08-28 10:42:27 -0400 | [diff] [blame] | 732 | } | 
| Brad Bishop | d14c2e2 | 2020-08-28 10:43:40 -0400 | [diff] [blame] | 733 |  | 
| Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 734 | TEST(MatchProbe, doubleNeqArray) | 
 | 735 | { | 
 | 736 |     nlohmann::json j = R"(-11.2)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 737 |     DBusValueVariant v = std::vector<uint8_t>{11}; | 
| Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 738 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 739 | } | 
 | 740 |  | 
| Brad Bishop | d14c2e2 | 2020-08-28 10:43:40 -0400 | [diff] [blame] | 741 | TEST(MatchProbe, arrayNeqString) | 
 | 742 | { | 
 | 743 |     nlohmann::json j = R"([1, 2])"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 744 |     DBusValueVariant v = "hello"s; | 
| Brad Bishop | d14c2e2 | 2020-08-28 10:43:40 -0400 | [diff] [blame] | 745 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 746 | } | 
 | 747 |  | 
 | 748 | TEST(MatchProbe, arrayNeqFalse) | 
 | 749 | { | 
 | 750 |     nlohmann::json j = R"([1, 2])"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 751 |     DBusValueVariant v = false; | 
| Brad Bishop | d14c2e2 | 2020-08-28 10:43:40 -0400 | [diff] [blame] | 752 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 753 | } | 
 | 754 |  | 
 | 755 | TEST(MatchProbe, arrayNeqTrue) | 
 | 756 | { | 
 | 757 |     nlohmann::json j = R"([1, 2])"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 758 |     DBusValueVariant v = true; | 
| Brad Bishop | d14c2e2 | 2020-08-28 10:43:40 -0400 | [diff] [blame] | 759 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 760 | } | 
 | 761 |  | 
 | 762 | TEST(MatchProbe, arrayNeqUint8) | 
 | 763 | { | 
 | 764 |     nlohmann::json j = R"([1, 2])"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 765 |     DBusValueVariant v = uint8_t(1); | 
| Brad Bishop | d14c2e2 | 2020-08-28 10:43:40 -0400 | [diff] [blame] | 766 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 767 | } | 
 | 768 |  | 
 | 769 | TEST(MatchProbe, arrayNeqInt32) | 
 | 770 | { | 
 | 771 |     nlohmann::json j = R"([1, 2])"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 772 |     DBusValueVariant v = int32_t(-1); | 
| Brad Bishop | d14c2e2 | 2020-08-28 10:43:40 -0400 | [diff] [blame] | 773 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 774 | } | 
 | 775 |  | 
 | 776 | TEST(MatchProbe, arrayNeqDouble) | 
 | 777 | { | 
 | 778 |     nlohmann::json j = R"([1, 2])"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 779 |     DBusValueVariant v = double(1.1); | 
| Brad Bishop | d14c2e2 | 2020-08-28 10:43:40 -0400 | [diff] [blame] | 780 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 781 | } | 
| Brad Bishop | 6660e2a | 2020-08-28 10:44:41 -0400 | [diff] [blame] | 782 |  | 
| Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 783 | TEST(MatchProbe, arrayEqArray) | 
 | 784 | { | 
 | 785 |     nlohmann::json j = R"([1, 2])"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 786 |     DBusValueVariant v = std::vector<uint8_t>{1, 2}; | 
| Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 787 |     EXPECT_TRUE(matchProbe(j, v)); | 
 | 788 | } | 
 | 789 |  | 
 | 790 | TEST(MatchProbe, arrayNeqArrayDiffSize1) | 
 | 791 | { | 
 | 792 |     nlohmann::json j = R"([1, 2, 3])"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 793 |     DBusValueVariant v = std::vector<uint8_t>{1, 2}; | 
| Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 794 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 795 | } | 
 | 796 |  | 
 | 797 | TEST(MatchProbe, arrayNeqArrayDiffSize2) | 
 | 798 | { | 
 | 799 |     nlohmann::json j = R"([1, 2])"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 800 |     DBusValueVariant v = std::vector<uint8_t>{1, 2, 3}; | 
| Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 801 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 802 | } | 
 | 803 |  | 
 | 804 | TEST(MatchProbe, emptyArrayEqEmptyArray) | 
 | 805 | { | 
 | 806 |     nlohmann::json j = R"([])"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 807 |     DBusValueVariant v = std::vector<uint8_t>{}; | 
| Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 808 |     EXPECT_TRUE(matchProbe(j, v)); | 
 | 809 | } | 
 | 810 |  | 
 | 811 | TEST(MatchProbe, emptyArrayNeqArray) | 
 | 812 | { | 
 | 813 |     nlohmann::json j = R"([])"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 814 |     DBusValueVariant v = std::vector<uint8_t>{1}; | 
| Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 815 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 816 | } | 
 | 817 |  | 
 | 818 | TEST(MatchProbe, arrayNeqEmptyArray) | 
 | 819 | { | 
 | 820 |     nlohmann::json j = R"([1])"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 821 |     DBusValueVariant v = std::vector<uint8_t>{}; | 
| Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 822 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 823 | } | 
 | 824 |  | 
| Brad Bishop | 6660e2a | 2020-08-28 10:44:41 -0400 | [diff] [blame] | 825 | TEST(MatchProbe, objNeqString) | 
 | 826 | { | 
 | 827 |     nlohmann::json j = R"({"foo": "bar"})"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 828 |     DBusValueVariant v = "hello"s; | 
| Brad Bishop | 6660e2a | 2020-08-28 10:44:41 -0400 | [diff] [blame] | 829 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 830 | } | 
 | 831 |  | 
 | 832 | TEST(MatchProbe, objNeqFalse) | 
 | 833 | { | 
 | 834 |     nlohmann::json j = R"({"foo": "bar"})"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 835 |     DBusValueVariant v = false; | 
| Brad Bishop | 6660e2a | 2020-08-28 10:44:41 -0400 | [diff] [blame] | 836 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 837 | } | 
 | 838 |  | 
 | 839 | TEST(MatchProbe, objNeqTrue) | 
 | 840 | { | 
 | 841 |     nlohmann::json j = R"({"foo": "bar"})"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 842 |     DBusValueVariant v = true; | 
| Brad Bishop | 6660e2a | 2020-08-28 10:44:41 -0400 | [diff] [blame] | 843 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 844 | } | 
 | 845 |  | 
 | 846 | TEST(MatchProbe, objNeqUint8) | 
 | 847 | { | 
 | 848 |     nlohmann::json j = R"({"foo": "bar"})"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 849 |     DBusValueVariant v = uint8_t(1); | 
| Brad Bishop | 6660e2a | 2020-08-28 10:44:41 -0400 | [diff] [blame] | 850 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 851 | } | 
 | 852 |  | 
 | 853 | TEST(MatchProbe, objNeqInt32) | 
 | 854 | { | 
 | 855 |     nlohmann::json j = R"({"foo": "bar"})"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 856 |     DBusValueVariant v = int32_t(-1); | 
| Brad Bishop | 6660e2a | 2020-08-28 10:44:41 -0400 | [diff] [blame] | 857 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 858 | } | 
 | 859 |  | 
 | 860 | TEST(MatchProbe, objNeqDouble) | 
 | 861 | { | 
 | 862 |     nlohmann::json j = R"({"foo": "bar"})"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 863 |     DBusValueVariant v = double(1.1); | 
| Brad Bishop | 6660e2a | 2020-08-28 10:44:41 -0400 | [diff] [blame] | 864 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 865 | } | 
| Brad Bishop | c776c41 | 2020-08-28 10:45:25 -0400 | [diff] [blame] | 866 |  | 
| Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 867 | TEST(MatchProbe, objNeqArray) | 
 | 868 | { | 
 | 869 |     nlohmann::json j = R"({"foo": "bar"})"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 870 |     DBusValueVariant v = std::vector<uint8_t>{1, 2}; | 
| Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 871 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 872 | } | 
 | 873 |  | 
| Brad Bishop | c776c41 | 2020-08-28 10:45:25 -0400 | [diff] [blame] | 874 | TEST(MatchProbe, nullNeqString) | 
 | 875 | { | 
 | 876 |     nlohmann::json j = R"(null)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 877 |     DBusValueVariant v = "hello"s; | 
| Brad Bishop | c776c41 | 2020-08-28 10:45:25 -0400 | [diff] [blame] | 878 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 879 | } | 
 | 880 |  | 
 | 881 | TEST(MatchProbe, nullNeqFalse) | 
 | 882 | { | 
 | 883 |     nlohmann::json j = R"(null)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 884 |     DBusValueVariant v = false; | 
| Brad Bishop | c776c41 | 2020-08-28 10:45:25 -0400 | [diff] [blame] | 885 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 886 | } | 
 | 887 |  | 
 | 888 | TEST(MatchProbe, nullNeqTrue) | 
 | 889 | { | 
 | 890 |     nlohmann::json j = R"(null)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 891 |     DBusValueVariant v = true; | 
| Brad Bishop | c776c41 | 2020-08-28 10:45:25 -0400 | [diff] [blame] | 892 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 893 | } | 
 | 894 |  | 
 | 895 | TEST(MatchProbe, nullNeqUint8) | 
 | 896 | { | 
 | 897 |     nlohmann::json j = R"(null)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 898 |     DBusValueVariant v = uint8_t(1); | 
| Brad Bishop | c776c41 | 2020-08-28 10:45:25 -0400 | [diff] [blame] | 899 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 900 | } | 
 | 901 |  | 
 | 902 | TEST(MatchProbe, nullNeqInt32) | 
 | 903 | { | 
 | 904 |     nlohmann::json j = R"(null)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 905 |     DBusValueVariant v = int32_t(-1); | 
| Brad Bishop | c776c41 | 2020-08-28 10:45:25 -0400 | [diff] [blame] | 906 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 907 | } | 
 | 908 |  | 
 | 909 | TEST(MatchProbe, nullNeqDouble) | 
 | 910 | { | 
 | 911 |     nlohmann::json j = R"(null)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 912 |     DBusValueVariant v = double(1.1); | 
| Brad Bishop | c776c41 | 2020-08-28 10:45:25 -0400 | [diff] [blame] | 913 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 914 | } | 
| Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 915 |  | 
 | 916 | TEST(MatchProbe, nullNeqArray) | 
 | 917 | { | 
 | 918 |     nlohmann::json j = R"(null)"_json; | 
| Andrew Jeffery | eab4929 | 2022-04-05 14:42:20 +0930 | [diff] [blame] | 919 |     DBusValueVariant v = std::vector<uint8_t>{}; | 
| Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 920 |     EXPECT_FALSE(matchProbe(j, v)); | 
 | 921 | } |