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