James Feist | 481c5d5 | 2019-08-13 14:40:40 -0700 | [diff] [blame] | 1 | #include "Utils.hpp" |
| 2 | |
| 3 | #include <boost/container/flat_map.hpp> |
| 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(); |
| 17 | boost::container::flat_map<std::string, BasicVariantType> data; |
| 18 | data["BUS"] = 23; |
| 19 | |
| 20 | templateCharReplace(it, data, 0); |
| 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(); |
| 30 | boost::container::flat_map<std::string, BasicVariantType> data; |
| 31 | data["TEST"] = std::string("Test"); |
| 32 | |
| 33 | templateCharReplace(it, data, 0); |
| 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(); |
| 43 | boost::container::flat_map<std::string, BasicVariantType> data; |
| 44 | data["TEST"] = std::string("Test"); |
| 45 | |
| 46 | templateCharReplace(it, data, 0); |
| 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(); |
| 56 | boost::container::flat_map<std::string, BasicVariantType> data; |
| 57 | data["TEST"] = std::string("Test"); |
| 58 | |
| 59 | templateCharReplace(it, data, 0); |
| 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(); |
| 69 | boost::container::flat_map<std::string, BasicVariantType> data; |
| 70 | data["TEST"] = 23; |
| 71 | |
| 72 | templateCharReplace(it, data, 0); |
| 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(); |
| 82 | boost::container::flat_map<std::string, BasicVariantType> data; |
| 83 | data["TEST"] = 3; |
| 84 | |
| 85 | templateCharReplace(it, data, 0); |
| 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(); |
| 95 | boost::container::flat_map<std::string, BasicVariantType> data; |
| 96 | data["TEST"] = 3; |
| 97 | |
| 98 | templateCharReplace(it, data, 0); |
| 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(); |
| 108 | boost::container::flat_map<std::string, BasicVariantType> data; |
| 109 | data["TEST"] = 3; |
| 110 | |
| 111 | templateCharReplace(it, data, 0); |
| 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(); |
| 121 | boost::container::flat_map<std::string, BasicVariantType> data; |
| 122 | data["TEST"] = 3; |
| 123 | |
| 124 | templateCharReplace(it, data, 0); |
| 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(); |
| 134 | boost::container::flat_map<std::string, BasicVariantType> data; |
| 135 | data["TEST"] = 4; |
| 136 | |
| 137 | templateCharReplace(it, data, 0); |
| 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(); |
| 147 | boost::container::flat_map<std::string, BasicVariantType> data; |
| 148 | data["TEST"] = 4; |
| 149 | |
| 150 | templateCharReplace(it, data, 0); |
| 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(); |
| 160 | boost::container::flat_map<std::string, BasicVariantType> data; |
| 161 | data["FOO"] = std::string("foo"); |
| 162 | data["BAR"] = std::string("bar"); |
| 163 | |
| 164 | templateCharReplace(it, data, 0); |
| 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(); |
| 174 | boost::container::flat_map<std::string, BasicVariantType> data; |
| 175 | data["TEST"] = 4; |
| 176 | data["BAR"] = std::string("bar"); |
| 177 | |
| 178 | templateCharReplace(it, data, 0); |
| 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(); |
| 187 | boost::container::flat_map<std::string, BasicVariantType> data; |
| 188 | data["ADDRESS"] = 4; |
| 189 | data["BAR"] = std::string("bar"); |
| 190 | |
| 191 | templateCharReplace(it, data, 0); |
| 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 | |
| 204 | boost::container::flat_map<std::string, BasicVariantType> data; |
| 205 | data["BUS"] = 15; |
| 206 | |
| 207 | for (auto it = j.begin(); it != j.end(); it++) |
| 208 | { |
| 209 | templateCharReplace(it, data, 0); |
| 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(); |
| 222 | boost::container::flat_map<std::string, BasicVariantType> data; |
| 223 | data["test"] = 12; |
| 224 | |
| 225 | templateCharReplace(it, data, 0); |
| 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(); |
| 235 | boost::container::flat_map<std::string, BasicVariantType> data; |
| 236 | |
| 237 | templateCharReplace(it, data, 0); |
| 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 | |
| 243 | TEST(MatchProbe, stringEqString) |
| 244 | { |
| 245 | nlohmann::json j = R"("foo")"_json; |
| 246 | BasicVariantType v = "foo"s; |
| 247 | EXPECT_TRUE(matchProbe(j, v)); |
| 248 | } |
| 249 | |
| 250 | TEST(MatchProbe, stringRegexEqString) |
| 251 | { |
| 252 | nlohmann::json j = R"("foo*")"_json; |
| 253 | BasicVariantType v = "foobar"s; |
| 254 | EXPECT_TRUE(matchProbe(j, v)); |
| 255 | } |
| 256 | |
| 257 | TEST(MatchProbe, stringNeqString) |
| 258 | { |
| 259 | nlohmann::json j = R"("foobar")"_json; |
| 260 | BasicVariantType v = "foo"s; |
| 261 | EXPECT_FALSE(matchProbe(j, v)); |
| 262 | } |
| 263 | |
| 264 | TEST(MatchProbe, stringRegexError) |
| 265 | { |
| 266 | nlohmann::json j = R"("foo[")"_json; |
| 267 | BasicVariantType v = "foobar"s; |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 268 | EXPECT_FALSE(matchProbe(j, v)); |
Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 269 | } |
| 270 | |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 271 | TEST(MatchProbe, stringZeroNeqFalse) |
Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 272 | { |
| 273 | nlohmann::json j = R"("0")"_json; |
| 274 | BasicVariantType v = false; |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 275 | EXPECT_FALSE(matchProbe(j, v)); |
Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 276 | } |
| 277 | |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 278 | TEST(MatchProbe, stringOneNeqTrue) |
Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 279 | { |
| 280 | nlohmann::json j = R"("1")"_json; |
| 281 | BasicVariantType v = true; |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 282 | EXPECT_FALSE(matchProbe(j, v)); |
Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | TEST(MatchProbe, stringElevenNeqTrue) |
| 286 | { |
| 287 | nlohmann::json j = R"("11")"_json; |
| 288 | BasicVariantType v = true; |
| 289 | EXPECT_FALSE(matchProbe(j, v)); |
| 290 | } |
| 291 | |
| 292 | TEST(MatchProbe, stringFalseNeqFalse) |
| 293 | { |
| 294 | nlohmann::json j = R"("false")"_json; |
| 295 | BasicVariantType v = false; |
| 296 | EXPECT_FALSE(matchProbe(j, v)); |
| 297 | } |
| 298 | |
| 299 | TEST(MatchProbe, stringTrueNeqTrue) |
| 300 | { |
| 301 | nlohmann::json j = R"("true")"_json; |
| 302 | BasicVariantType v = true; |
| 303 | EXPECT_FALSE(matchProbe(j, v)); |
| 304 | } |
| 305 | |
| 306 | TEST(MatchProbe, stringFalseNeqTrue) |
| 307 | { |
| 308 | nlohmann::json j = R"("false")"_json; |
| 309 | BasicVariantType v = true; |
| 310 | EXPECT_FALSE(matchProbe(j, v)); |
| 311 | } |
| 312 | |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 313 | TEST(MatchProbe, stringNeqUint8) |
Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 314 | { |
| 315 | nlohmann::json j = R"("255")"_json; |
| 316 | BasicVariantType v = uint8_t(255); |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 317 | EXPECT_FALSE(matchProbe(j, v)); |
Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | TEST(MatchProbe, stringNeqUint8Overflow) |
| 321 | { |
| 322 | nlohmann::json j = R"("65535")"_json; |
| 323 | BasicVariantType v = uint8_t(255); |
| 324 | EXPECT_FALSE(matchProbe(j, v)); |
| 325 | } |
| 326 | |
| 327 | TEST(MatchProbe, stringFalseNeqUint8Zero) |
| 328 | { |
| 329 | nlohmann::json j = R"("false")"_json; |
| 330 | BasicVariantType v = uint8_t(0); |
| 331 | EXPECT_FALSE(matchProbe(j, v)); |
| 332 | } |
| 333 | |
| 334 | TEST(MatchProbe, stringTrueNeqUint8Zero) |
| 335 | { |
| 336 | nlohmann::json j = R"("true")"_json; |
| 337 | BasicVariantType v = uint8_t(1); |
| 338 | EXPECT_FALSE(matchProbe(j, v)); |
| 339 | } |
| 340 | |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 341 | TEST(MatchProbe, stringNeqUint32) |
Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 342 | { |
| 343 | nlohmann::json j = R"("11")"_json; |
| 344 | BasicVariantType v = uint32_t(11); |
Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 345 | EXPECT_FALSE(matchProbe(j, v)); |
| 346 | } |
| 347 | |
Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 348 | TEST(MatchProbe, stringNeqInt32) |
| 349 | { |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 350 | nlohmann::json j = R"("-11")"_json; |
Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 351 | BasicVariantType v = int32_t(-11); |
| 352 | EXPECT_FALSE(matchProbe(j, v)); |
| 353 | } |
| 354 | |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 355 | TEST(MatchProbe, stringRegexNeqInt32) |
Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 356 | { |
| 357 | nlohmann::json j = R"("1*4")"_json; |
| 358 | BasicVariantType v = int32_t(124); |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 359 | EXPECT_FALSE(matchProbe(j, v)); |
Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 360 | } |
| 361 | |
| 362 | TEST(MatchProbe, stringNeqUint64) |
| 363 | { |
| 364 | nlohmann::json j = R"("foo")"_json; |
| 365 | BasicVariantType v = uint64_t(65535); |
| 366 | EXPECT_FALSE(matchProbe(j, v)); |
| 367 | } |
| 368 | |
Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 369 | TEST(MatchProbe, stringNeqDouble) |
| 370 | { |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 371 | nlohmann::json j = R"("123.4")"_json; |
Brad Bishop | 9d2ef08 | 2020-08-26 15:17:55 -0400 | [diff] [blame] | 372 | BasicVariantType v = double(123.4); |
| 373 | EXPECT_FALSE(matchProbe(j, v)); |
| 374 | } |
| 375 | |
| 376 | TEST(MatchProbe, stringNeqEmpty) |
| 377 | { |
| 378 | nlohmann::json j = R"("-123.4")"_json; |
| 379 | BasicVariantType v; |
| 380 | EXPECT_FALSE(matchProbe(j, v)); |
| 381 | } |
Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 382 | |
Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 383 | TEST(MatchProbe, stringNeqArray) |
| 384 | { |
| 385 | nlohmann::json j = R"("-123.4")"_json; |
| 386 | BasicVariantType v = std::vector<uint8_t>{1, 2}; |
| 387 | EXPECT_FALSE(matchProbe(j, v)); |
| 388 | } |
| 389 | |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 390 | TEST(MatchProbe, boolNeqString) |
Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 391 | { |
| 392 | nlohmann::json j = R"(false)"_json; |
| 393 | BasicVariantType v = "false"s; |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 394 | EXPECT_FALSE(matchProbe(j, v)); |
Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 395 | } |
| 396 | |
| 397 | TEST(MatchProbe, trueEqTrue) |
| 398 | { |
| 399 | nlohmann::json j = R"(true)"_json; |
| 400 | BasicVariantType v = true; |
| 401 | EXPECT_TRUE(matchProbe(j, v)); |
| 402 | } |
| 403 | |
| 404 | TEST(MatchProbe, falseEqFalse) |
| 405 | { |
| 406 | nlohmann::json j = R"(false)"_json; |
| 407 | BasicVariantType v = false; |
| 408 | EXPECT_TRUE(matchProbe(j, v)); |
| 409 | } |
| 410 | |
| 411 | TEST(MatchProbe, trueNeqFalse) |
| 412 | { |
| 413 | nlohmann::json j = R"(true)"_json; |
| 414 | BasicVariantType v = false; |
| 415 | EXPECT_FALSE(matchProbe(j, v)); |
| 416 | } |
| 417 | |
| 418 | TEST(MatchProbe, trueNeqInt32Zero) |
| 419 | { |
| 420 | nlohmann::json j = R"(true)"_json; |
| 421 | BasicVariantType v = int32_t(0); |
| 422 | EXPECT_FALSE(matchProbe(j, v)); |
| 423 | } |
| 424 | |
| 425 | TEST(MatchProbe, trueNeqInt32NegativeOne) |
| 426 | { |
| 427 | nlohmann::json j = R"(true)"_json; |
| 428 | BasicVariantType v = int32_t(-1); |
| 429 | EXPECT_FALSE(matchProbe(j, v)); |
| 430 | } |
| 431 | |
| 432 | TEST(MatchProbe, falseNeqUint32One) |
| 433 | { |
| 434 | nlohmann::json j = R"(false)"_json; |
| 435 | BasicVariantType v = uint32_t(1); |
| 436 | EXPECT_FALSE(matchProbe(j, v)); |
| 437 | } |
| 438 | |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 439 | TEST(MatchProbe, falseNeqUint32Zero) |
Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 440 | { |
| 441 | nlohmann::json j = R"(false)"_json; |
| 442 | BasicVariantType v = uint32_t(0); |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 443 | EXPECT_FALSE(matchProbe(j, v)); |
Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 444 | } |
| 445 | |
| 446 | TEST(MatchProbe, trueNeqDoubleNegativeOne) |
| 447 | { |
| 448 | nlohmann::json j = R"(true)"_json; |
| 449 | BasicVariantType v = double(-1.1); |
| 450 | EXPECT_FALSE(matchProbe(j, v)); |
| 451 | } |
| 452 | |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 453 | TEST(MatchProbe, trueNeqDoubleOne) |
Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 454 | { |
| 455 | nlohmann::json j = R"(true)"_json; |
| 456 | BasicVariantType v = double(1.0); |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 457 | EXPECT_FALSE(matchProbe(j, v)); |
Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 458 | } |
| 459 | |
| 460 | TEST(MatchProbe, falseNeqDoubleOne) |
| 461 | { |
| 462 | nlohmann::json j = R"(false)"_json; |
| 463 | BasicVariantType v = double(1.0); |
| 464 | EXPECT_FALSE(matchProbe(j, v)); |
| 465 | } |
| 466 | |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 467 | TEST(MatchProbe, falseNeqDoubleZero) |
Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 468 | { |
| 469 | nlohmann::json j = R"(false)"_json; |
| 470 | BasicVariantType v = double(0.0); |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 471 | EXPECT_FALSE(matchProbe(j, v)); |
Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 472 | } |
| 473 | |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 474 | TEST(MatchProbe, falseNeqEmpty) |
Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 475 | { |
| 476 | nlohmann::json j = R"(false)"_json; |
| 477 | BasicVariantType v; |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 478 | EXPECT_FALSE(matchProbe(j, v)); |
Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 479 | } |
| 480 | |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 481 | TEST(MatchProbe, trueNeqEmpty) |
Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 482 | { |
| 483 | nlohmann::json j = R"(true)"_json; |
| 484 | BasicVariantType v; |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 485 | EXPECT_FALSE(matchProbe(j, v)); |
Brad Bishop | c5eba59 | 2020-08-28 10:38:24 -0400 | [diff] [blame] | 486 | } |
Brad Bishop | c2af531 | 2020-08-28 10:39:49 -0400 | [diff] [blame] | 487 | |
Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 488 | TEST(MatchProbe, trueNeqArray) |
| 489 | { |
| 490 | nlohmann::json j = R"(true)"_json; |
| 491 | BasicVariantType v = std::vector<uint8_t>{1, 2}; |
| 492 | EXPECT_FALSE(matchProbe(j, v)); |
| 493 | } |
| 494 | |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 495 | TEST(MatchProbe, uintNeqString) |
Brad Bishop | c2af531 | 2020-08-28 10:39:49 -0400 | [diff] [blame] | 496 | { |
| 497 | nlohmann::json j = R"(11)"_json; |
| 498 | BasicVariantType v = "11"s; |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 499 | EXPECT_FALSE(matchProbe(j, v)); |
Brad Bishop | c2af531 | 2020-08-28 10:39:49 -0400 | [diff] [blame] | 500 | } |
| 501 | |
| 502 | TEST(MatchProbe, uintNeqTrue) |
| 503 | { |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 504 | nlohmann::json j = R"(1)"_json; |
Brad Bishop | c2af531 | 2020-08-28 10:39:49 -0400 | [diff] [blame] | 505 | BasicVariantType v = true; |
| 506 | EXPECT_FALSE(matchProbe(j, v)); |
| 507 | } |
| 508 | |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 509 | TEST(MatchProbe, uintNeqFalse) |
| 510 | { |
| 511 | nlohmann::json j = R"(0)"_json; |
| 512 | BasicVariantType v = false; |
| 513 | EXPECT_FALSE(matchProbe(j, v)); |
| 514 | } |
| 515 | |
Brad Bishop | c2af531 | 2020-08-28 10:39:49 -0400 | [diff] [blame] | 516 | TEST(MatchProbe, uintEqUint8) |
| 517 | { |
| 518 | nlohmann::json j = R"(11)"_json; |
| 519 | BasicVariantType v = uint8_t(11); |
| 520 | EXPECT_TRUE(matchProbe(j, v)); |
| 521 | } |
| 522 | |
| 523 | TEST(MatchProbe, uintNeqUint8) |
| 524 | { |
| 525 | nlohmann::json j = R"(11)"_json; |
| 526 | BasicVariantType v = uint8_t(12); |
| 527 | EXPECT_FALSE(matchProbe(j, v)); |
| 528 | } |
| 529 | |
| 530 | TEST(MatchProbe, uintNeqUint8Overflow) |
| 531 | { |
| 532 | nlohmann::json j = R"(65535)"_json; |
| 533 | BasicVariantType v = uint8_t(255); |
| 534 | EXPECT_FALSE(matchProbe(j, v)); |
| 535 | } |
| 536 | |
| 537 | TEST(MatchProbe, uintEqInt8) |
| 538 | { |
| 539 | nlohmann::json j = R"(11)"_json; |
| 540 | BasicVariantType v = int8_t(11); |
| 541 | EXPECT_TRUE(matchProbe(j, v)); |
| 542 | } |
| 543 | |
| 544 | TEST(MatchProbe, uintEqDouble) |
| 545 | { |
| 546 | nlohmann::json j = R"(11)"_json; |
| 547 | BasicVariantType v = double(11.0); |
| 548 | EXPECT_TRUE(matchProbe(j, v)); |
| 549 | } |
| 550 | |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 551 | TEST(MatchProbe, uintNeqDouble) |
Brad Bishop | c2af531 | 2020-08-28 10:39:49 -0400 | [diff] [blame] | 552 | { |
| 553 | nlohmann::json j = R"(11)"_json; |
| 554 | BasicVariantType v = double(11.7); |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 555 | EXPECT_FALSE(matchProbe(j, v)); |
Brad Bishop | c2af531 | 2020-08-28 10:39:49 -0400 | [diff] [blame] | 556 | } |
| 557 | |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 558 | TEST(MatchProbe, uintNeqEmpty) |
Brad Bishop | c2af531 | 2020-08-28 10:39:49 -0400 | [diff] [blame] | 559 | { |
| 560 | nlohmann::json j = R"(11)"_json; |
| 561 | BasicVariantType v; |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 562 | EXPECT_FALSE(matchProbe(j, v)); |
Brad Bishop | c2af531 | 2020-08-28 10:39:49 -0400 | [diff] [blame] | 563 | } |
Brad Bishop | 667e050 | 2020-08-28 10:41:40 -0400 | [diff] [blame] | 564 | |
Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 565 | TEST(MatchProbe, uintNeqArray) |
| 566 | { |
| 567 | nlohmann::json j = R"(11)"_json; |
| 568 | BasicVariantType v = std::vector<uint8_t>{11}; |
| 569 | EXPECT_FALSE(matchProbe(j, v)); |
| 570 | } |
| 571 | |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 572 | TEST(MatchProbe, intNeqString) |
Brad Bishop | 667e050 | 2020-08-28 10:41:40 -0400 | [diff] [blame] | 573 | { |
| 574 | nlohmann::json j = R"(-11)"_json; |
| 575 | BasicVariantType v = "-11"s; |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 576 | EXPECT_FALSE(matchProbe(j, v)); |
Brad Bishop | 667e050 | 2020-08-28 10:41:40 -0400 | [diff] [blame] | 577 | } |
| 578 | |
| 579 | TEST(MatchProbe, intNeqTrue) |
| 580 | { |
| 581 | nlohmann::json j = R"(-1)"_json; |
| 582 | BasicVariantType v = true; |
| 583 | EXPECT_FALSE(matchProbe(j, v)); |
| 584 | } |
| 585 | |
| 586 | TEST(MatchProbe, intNeqUint8) |
| 587 | { |
| 588 | nlohmann::json j = R"(-11)"_json; |
| 589 | BasicVariantType v = uint8_t(11); |
| 590 | EXPECT_FALSE(matchProbe(j, v)); |
| 591 | } |
| 592 | |
| 593 | TEST(MatchProbe, intEqInt8) |
| 594 | { |
| 595 | nlohmann::json j = R"(-11)"_json; |
| 596 | BasicVariantType v = int8_t(-11); |
| 597 | EXPECT_TRUE(matchProbe(j, v)); |
| 598 | } |
| 599 | |
| 600 | TEST(MatchProbe, intNeqDouble) |
| 601 | { |
| 602 | nlohmann::json j = R"(-124)"_json; |
| 603 | BasicVariantType v = double(-123.0); |
| 604 | EXPECT_FALSE(matchProbe(j, v)); |
| 605 | } |
| 606 | |
| 607 | TEST(MatchProbe, intEqDouble) |
| 608 | { |
| 609 | nlohmann::json j = R"(-11)"_json; |
| 610 | BasicVariantType v = double(-11.0); |
| 611 | EXPECT_TRUE(matchProbe(j, v)); |
| 612 | } |
| 613 | |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 614 | TEST(MatchProbe, intNeqDoubleRound) |
Brad Bishop | 667e050 | 2020-08-28 10:41:40 -0400 | [diff] [blame] | 615 | { |
| 616 | nlohmann::json j = R"(-11)"_json; |
| 617 | BasicVariantType v = double(-11.7); |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 618 | EXPECT_FALSE(matchProbe(j, v)); |
Brad Bishop | 667e050 | 2020-08-28 10:41:40 -0400 | [diff] [blame] | 619 | } |
| 620 | |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 621 | TEST(MatchProbe, intNeqEmpty) |
Brad Bishop | 667e050 | 2020-08-28 10:41:40 -0400 | [diff] [blame] | 622 | { |
| 623 | nlohmann::json j = R"(-11)"_json; |
| 624 | BasicVariantType v; |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 625 | EXPECT_FALSE(matchProbe(j, v)); |
Brad Bishop | 667e050 | 2020-08-28 10:41:40 -0400 | [diff] [blame] | 626 | } |
Brad Bishop | 3bd8e8d | 2020-08-28 10:42:27 -0400 | [diff] [blame] | 627 | |
Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 628 | TEST(MatchProbe, intNeqArray) |
| 629 | { |
| 630 | nlohmann::json j = R"(-11)"_json; |
| 631 | BasicVariantType v = std::vector<uint8_t>{11}; |
| 632 | EXPECT_FALSE(matchProbe(j, v)); |
| 633 | } |
| 634 | |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 635 | TEST(MatchProbe, doubleNeqString) |
Brad Bishop | 3bd8e8d | 2020-08-28 10:42:27 -0400 | [diff] [blame] | 636 | { |
| 637 | nlohmann::json j = R"(0.0)"_json; |
| 638 | BasicVariantType v = "0.0"s; |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 639 | EXPECT_FALSE(matchProbe(j, v)); |
Brad Bishop | 3bd8e8d | 2020-08-28 10:42:27 -0400 | [diff] [blame] | 640 | } |
| 641 | |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 642 | TEST(MatchProbe, doubleNeqFalse) |
Brad Bishop | 3bd8e8d | 2020-08-28 10:42:27 -0400 | [diff] [blame] | 643 | { |
| 644 | nlohmann::json j = R"(0.0)"_json; |
| 645 | BasicVariantType v = false; |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 646 | EXPECT_FALSE(matchProbe(j, v)); |
Brad Bishop | 3bd8e8d | 2020-08-28 10:42:27 -0400 | [diff] [blame] | 647 | } |
| 648 | |
| 649 | TEST(MatchProbe, doubleNeqTrue) |
| 650 | { |
Brad Bishop | 3bd8e8d | 2020-08-28 10:42:27 -0400 | [diff] [blame] | 651 | nlohmann::json j = R"(1.0)"_json; |
| 652 | BasicVariantType v = true; |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 653 | EXPECT_FALSE(matchProbe(j, v)); |
Brad Bishop | 3bd8e8d | 2020-08-28 10:42:27 -0400 | [diff] [blame] | 654 | } |
| 655 | |
| 656 | TEST(MatchProbe, doubleEqInt32) |
| 657 | { |
| 658 | nlohmann::json j = R"(-124.0)"_json; |
| 659 | BasicVariantType v = int32_t(-124); |
| 660 | EXPECT_TRUE(matchProbe(j, v)); |
| 661 | } |
| 662 | |
| 663 | TEST(MatchProbe, doubleNeqInt32) |
| 664 | { |
| 665 | nlohmann::json j = R"(-124.0)"_json; |
| 666 | BasicVariantType v = int32_t(-123); |
| 667 | EXPECT_FALSE(matchProbe(j, v)); |
| 668 | } |
| 669 | |
| 670 | TEST(MatchProbe, doubleRoundNeqInt) |
| 671 | { |
| 672 | nlohmann::json j = R"(124.7)"_json; |
| 673 | BasicVariantType v = int32_t(124); |
| 674 | EXPECT_FALSE(matchProbe(j, v)); |
| 675 | } |
| 676 | TEST(MatchProbe, doubleEqDouble) |
| 677 | { |
| 678 | nlohmann::json j = R"(-124.2)"_json; |
| 679 | BasicVariantType v = double(-124.2); |
| 680 | EXPECT_TRUE(matchProbe(j, v)); |
| 681 | } |
| 682 | |
| 683 | TEST(MatchProbe, doubleNeqDouble) |
| 684 | { |
| 685 | nlohmann::json j = R"(-124.3)"_json; |
| 686 | BasicVariantType v = double(-124.2); |
| 687 | EXPECT_FALSE(matchProbe(j, v)); |
| 688 | } |
| 689 | |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 690 | TEST(MatchProbe, doubleNeqEmpty) |
Brad Bishop | 3bd8e8d | 2020-08-28 10:42:27 -0400 | [diff] [blame] | 691 | { |
| 692 | nlohmann::json j = R"(-11.0)"_json; |
| 693 | BasicVariantType v; |
Brad Bishop | 5d52541 | 2020-08-26 08:50:50 -0400 | [diff] [blame] | 694 | EXPECT_FALSE(matchProbe(j, v)); |
Brad Bishop | 3bd8e8d | 2020-08-28 10:42:27 -0400 | [diff] [blame] | 695 | } |
Brad Bishop | d14c2e2 | 2020-08-28 10:43:40 -0400 | [diff] [blame] | 696 | |
Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 697 | TEST(MatchProbe, doubleNeqArray) |
| 698 | { |
| 699 | nlohmann::json j = R"(-11.2)"_json; |
| 700 | BasicVariantType v = std::vector<uint8_t>{11}; |
| 701 | EXPECT_FALSE(matchProbe(j, v)); |
| 702 | } |
| 703 | |
Brad Bishop | d14c2e2 | 2020-08-28 10:43:40 -0400 | [diff] [blame] | 704 | TEST(MatchProbe, arrayNeqString) |
| 705 | { |
| 706 | nlohmann::json j = R"([1, 2])"_json; |
| 707 | BasicVariantType v = "hello"s; |
| 708 | EXPECT_FALSE(matchProbe(j, v)); |
| 709 | } |
| 710 | |
| 711 | TEST(MatchProbe, arrayNeqFalse) |
| 712 | { |
| 713 | nlohmann::json j = R"([1, 2])"_json; |
| 714 | BasicVariantType v = false; |
| 715 | EXPECT_FALSE(matchProbe(j, v)); |
| 716 | } |
| 717 | |
| 718 | TEST(MatchProbe, arrayNeqTrue) |
| 719 | { |
| 720 | nlohmann::json j = R"([1, 2])"_json; |
| 721 | BasicVariantType v = true; |
| 722 | EXPECT_FALSE(matchProbe(j, v)); |
| 723 | } |
| 724 | |
| 725 | TEST(MatchProbe, arrayNeqUint8) |
| 726 | { |
| 727 | nlohmann::json j = R"([1, 2])"_json; |
| 728 | BasicVariantType v = uint8_t(1); |
| 729 | EXPECT_FALSE(matchProbe(j, v)); |
| 730 | } |
| 731 | |
| 732 | TEST(MatchProbe, arrayNeqInt32) |
| 733 | { |
| 734 | nlohmann::json j = R"([1, 2])"_json; |
| 735 | BasicVariantType v = int32_t(-1); |
| 736 | EXPECT_FALSE(matchProbe(j, v)); |
| 737 | } |
| 738 | |
| 739 | TEST(MatchProbe, arrayNeqDouble) |
| 740 | { |
| 741 | nlohmann::json j = R"([1, 2])"_json; |
| 742 | BasicVariantType v = double(1.1); |
| 743 | EXPECT_FALSE(matchProbe(j, v)); |
| 744 | } |
Brad Bishop | 6660e2a | 2020-08-28 10:44:41 -0400 | [diff] [blame] | 745 | |
Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 746 | TEST(MatchProbe, arrayEqArray) |
| 747 | { |
| 748 | nlohmann::json j = R"([1, 2])"_json; |
| 749 | BasicVariantType v = std::vector<uint8_t>{1, 2}; |
| 750 | EXPECT_TRUE(matchProbe(j, v)); |
| 751 | } |
| 752 | |
| 753 | TEST(MatchProbe, arrayNeqArrayDiffSize1) |
| 754 | { |
| 755 | nlohmann::json j = R"([1, 2, 3])"_json; |
| 756 | BasicVariantType v = std::vector<uint8_t>{1, 2}; |
| 757 | EXPECT_FALSE(matchProbe(j, v)); |
| 758 | } |
| 759 | |
| 760 | TEST(MatchProbe, arrayNeqArrayDiffSize2) |
| 761 | { |
| 762 | nlohmann::json j = R"([1, 2])"_json; |
| 763 | BasicVariantType v = std::vector<uint8_t>{1, 2, 3}; |
| 764 | EXPECT_FALSE(matchProbe(j, v)); |
| 765 | } |
| 766 | |
| 767 | TEST(MatchProbe, emptyArrayEqEmptyArray) |
| 768 | { |
| 769 | nlohmann::json j = R"([])"_json; |
| 770 | BasicVariantType v = std::vector<uint8_t>{}; |
| 771 | EXPECT_TRUE(matchProbe(j, v)); |
| 772 | } |
| 773 | |
| 774 | TEST(MatchProbe, emptyArrayNeqArray) |
| 775 | { |
| 776 | nlohmann::json j = R"([])"_json; |
| 777 | BasicVariantType v = std::vector<uint8_t>{1}; |
| 778 | EXPECT_FALSE(matchProbe(j, v)); |
| 779 | } |
| 780 | |
| 781 | TEST(MatchProbe, arrayNeqEmptyArray) |
| 782 | { |
| 783 | nlohmann::json j = R"([1])"_json; |
| 784 | BasicVariantType v = std::vector<uint8_t>{}; |
| 785 | EXPECT_FALSE(matchProbe(j, v)); |
| 786 | } |
| 787 | |
Brad Bishop | 6660e2a | 2020-08-28 10:44:41 -0400 | [diff] [blame] | 788 | TEST(MatchProbe, objNeqString) |
| 789 | { |
| 790 | nlohmann::json j = R"({"foo": "bar"})"_json; |
| 791 | BasicVariantType v = "hello"s; |
| 792 | EXPECT_FALSE(matchProbe(j, v)); |
| 793 | } |
| 794 | |
| 795 | TEST(MatchProbe, objNeqFalse) |
| 796 | { |
| 797 | nlohmann::json j = R"({"foo": "bar"})"_json; |
| 798 | BasicVariantType v = false; |
| 799 | EXPECT_FALSE(matchProbe(j, v)); |
| 800 | } |
| 801 | |
| 802 | TEST(MatchProbe, objNeqTrue) |
| 803 | { |
| 804 | nlohmann::json j = R"({"foo": "bar"})"_json; |
| 805 | BasicVariantType v = true; |
| 806 | EXPECT_FALSE(matchProbe(j, v)); |
| 807 | } |
| 808 | |
| 809 | TEST(MatchProbe, objNeqUint8) |
| 810 | { |
| 811 | nlohmann::json j = R"({"foo": "bar"})"_json; |
| 812 | BasicVariantType v = uint8_t(1); |
| 813 | EXPECT_FALSE(matchProbe(j, v)); |
| 814 | } |
| 815 | |
| 816 | TEST(MatchProbe, objNeqInt32) |
| 817 | { |
| 818 | nlohmann::json j = R"({"foo": "bar"})"_json; |
| 819 | BasicVariantType v = int32_t(-1); |
| 820 | EXPECT_FALSE(matchProbe(j, v)); |
| 821 | } |
| 822 | |
| 823 | TEST(MatchProbe, objNeqDouble) |
| 824 | { |
| 825 | nlohmann::json j = R"({"foo": "bar"})"_json; |
| 826 | BasicVariantType v = double(1.1); |
| 827 | EXPECT_FALSE(matchProbe(j, v)); |
| 828 | } |
Brad Bishop | c776c41 | 2020-08-28 10:45:25 -0400 | [diff] [blame] | 829 | |
Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 830 | TEST(MatchProbe, objNeqArray) |
| 831 | { |
| 832 | nlohmann::json j = R"({"foo": "bar"})"_json; |
| 833 | BasicVariantType v = std::vector<uint8_t>{1, 2}; |
| 834 | EXPECT_FALSE(matchProbe(j, v)); |
| 835 | } |
| 836 | |
Brad Bishop | c776c41 | 2020-08-28 10:45:25 -0400 | [diff] [blame] | 837 | TEST(MatchProbe, nullNeqString) |
| 838 | { |
| 839 | nlohmann::json j = R"(null)"_json; |
| 840 | BasicVariantType v = "hello"s; |
| 841 | EXPECT_FALSE(matchProbe(j, v)); |
| 842 | } |
| 843 | |
| 844 | TEST(MatchProbe, nullNeqFalse) |
| 845 | { |
| 846 | nlohmann::json j = R"(null)"_json; |
| 847 | BasicVariantType v = false; |
| 848 | EXPECT_FALSE(matchProbe(j, v)); |
| 849 | } |
| 850 | |
| 851 | TEST(MatchProbe, nullNeqTrue) |
| 852 | { |
| 853 | nlohmann::json j = R"(null)"_json; |
| 854 | BasicVariantType v = true; |
| 855 | EXPECT_FALSE(matchProbe(j, v)); |
| 856 | } |
| 857 | |
| 858 | TEST(MatchProbe, nullNeqUint8) |
| 859 | { |
| 860 | nlohmann::json j = R"(null)"_json; |
| 861 | BasicVariantType v = uint8_t(1); |
| 862 | EXPECT_FALSE(matchProbe(j, v)); |
| 863 | } |
| 864 | |
| 865 | TEST(MatchProbe, nullNeqInt32) |
| 866 | { |
| 867 | nlohmann::json j = R"(null)"_json; |
| 868 | BasicVariantType v = int32_t(-1); |
| 869 | EXPECT_FALSE(matchProbe(j, v)); |
| 870 | } |
| 871 | |
| 872 | TEST(MatchProbe, nullNeqDouble) |
| 873 | { |
| 874 | nlohmann::json j = R"(null)"_json; |
| 875 | BasicVariantType v = double(1.1); |
| 876 | EXPECT_FALSE(matchProbe(j, v)); |
| 877 | } |
Brad Bishop | cd1868e | 2020-08-28 17:58:52 -0400 | [diff] [blame] | 878 | |
| 879 | TEST(MatchProbe, nullNeqArray) |
| 880 | { |
| 881 | nlohmann::json j = R"(null)"_json; |
| 882 | BasicVariantType v = std::vector<uint8_t>{}; |
| 883 | EXPECT_FALSE(matchProbe(j, v)); |
| 884 | } |