1 #include "Utils.hpp" 2 3 #include <boost/container/flat_map.hpp> 4 #include <nlohmann/json.hpp> 5 6 #include <string> 7 #include <variant> 8 9 #include "gtest/gtest.h" 10 11 using namespace std::string_literals; 12 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 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 } 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"]); 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"; 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"; 194 EXPECT_EQ(expected, j["foo"]); 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 } 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 } 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; 268 EXPECT_FALSE(matchProbe(j, v)); 269 } 270 271 TEST(MatchProbe, stringZeroNeqFalse) 272 { 273 nlohmann::json j = R"("0")"_json; 274 BasicVariantType v = false; 275 EXPECT_FALSE(matchProbe(j, v)); 276 } 277 278 TEST(MatchProbe, stringOneNeqTrue) 279 { 280 nlohmann::json j = R"("1")"_json; 281 BasicVariantType v = true; 282 EXPECT_FALSE(matchProbe(j, v)); 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 313 TEST(MatchProbe, stringNeqUint8) 314 { 315 nlohmann::json j = R"("255")"_json; 316 BasicVariantType v = uint8_t(255); 317 EXPECT_FALSE(matchProbe(j, v)); 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 341 TEST(MatchProbe, stringNeqUint32) 342 { 343 nlohmann::json j = R"("11")"_json; 344 BasicVariantType v = uint32_t(11); 345 EXPECT_FALSE(matchProbe(j, v)); 346 } 347 348 TEST(MatchProbe, stringNeqInt32) 349 { 350 nlohmann::json j = R"("-11")"_json; 351 BasicVariantType v = int32_t(-11); 352 EXPECT_FALSE(matchProbe(j, v)); 353 } 354 355 TEST(MatchProbe, stringRegexNeqInt32) 356 { 357 nlohmann::json j = R"("1*4")"_json; 358 BasicVariantType v = int32_t(124); 359 EXPECT_FALSE(matchProbe(j, v)); 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 369 TEST(MatchProbe, stringNeqDouble) 370 { 371 nlohmann::json j = R"("123.4")"_json; 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 } 382 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 390 TEST(MatchProbe, boolNeqString) 391 { 392 nlohmann::json j = R"(false)"_json; 393 BasicVariantType v = "false"s; 394 EXPECT_FALSE(matchProbe(j, v)); 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 439 TEST(MatchProbe, falseNeqUint32Zero) 440 { 441 nlohmann::json j = R"(false)"_json; 442 BasicVariantType v = uint32_t(0); 443 EXPECT_FALSE(matchProbe(j, v)); 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 453 TEST(MatchProbe, trueNeqDoubleOne) 454 { 455 nlohmann::json j = R"(true)"_json; 456 BasicVariantType v = double(1.0); 457 EXPECT_FALSE(matchProbe(j, v)); 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 467 TEST(MatchProbe, falseNeqDoubleZero) 468 { 469 nlohmann::json j = R"(false)"_json; 470 BasicVariantType v = double(0.0); 471 EXPECT_FALSE(matchProbe(j, v)); 472 } 473 474 TEST(MatchProbe, falseNeqEmpty) 475 { 476 nlohmann::json j = R"(false)"_json; 477 BasicVariantType v; 478 EXPECT_FALSE(matchProbe(j, v)); 479 } 480 481 TEST(MatchProbe, trueNeqEmpty) 482 { 483 nlohmann::json j = R"(true)"_json; 484 BasicVariantType v; 485 EXPECT_FALSE(matchProbe(j, v)); 486 } 487 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 495 TEST(MatchProbe, uintNeqString) 496 { 497 nlohmann::json j = R"(11)"_json; 498 BasicVariantType v = "11"s; 499 EXPECT_FALSE(matchProbe(j, v)); 500 } 501 502 TEST(MatchProbe, uintNeqTrue) 503 { 504 nlohmann::json j = R"(1)"_json; 505 BasicVariantType v = true; 506 EXPECT_FALSE(matchProbe(j, v)); 507 } 508 509 TEST(MatchProbe, uintNeqFalse) 510 { 511 nlohmann::json j = R"(0)"_json; 512 BasicVariantType v = false; 513 EXPECT_FALSE(matchProbe(j, v)); 514 } 515 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 551 TEST(MatchProbe, uintNeqDouble) 552 { 553 nlohmann::json j = R"(11)"_json; 554 BasicVariantType v = double(11.7); 555 EXPECT_FALSE(matchProbe(j, v)); 556 } 557 558 TEST(MatchProbe, uintNeqEmpty) 559 { 560 nlohmann::json j = R"(11)"_json; 561 BasicVariantType v; 562 EXPECT_FALSE(matchProbe(j, v)); 563 } 564 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 572 TEST(MatchProbe, intNeqString) 573 { 574 nlohmann::json j = R"(-11)"_json; 575 BasicVariantType v = "-11"s; 576 EXPECT_FALSE(matchProbe(j, v)); 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 614 TEST(MatchProbe, intNeqDoubleRound) 615 { 616 nlohmann::json j = R"(-11)"_json; 617 BasicVariantType v = double(-11.7); 618 EXPECT_FALSE(matchProbe(j, v)); 619 } 620 621 TEST(MatchProbe, intNeqEmpty) 622 { 623 nlohmann::json j = R"(-11)"_json; 624 BasicVariantType v; 625 EXPECT_FALSE(matchProbe(j, v)); 626 } 627 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 635 TEST(MatchProbe, doubleNeqString) 636 { 637 nlohmann::json j = R"(0.0)"_json; 638 BasicVariantType v = "0.0"s; 639 EXPECT_FALSE(matchProbe(j, v)); 640 } 641 642 TEST(MatchProbe, doubleNeqFalse) 643 { 644 nlohmann::json j = R"(0.0)"_json; 645 BasicVariantType v = false; 646 EXPECT_FALSE(matchProbe(j, v)); 647 } 648 649 TEST(MatchProbe, doubleNeqTrue) 650 { 651 nlohmann::json j = R"(1.0)"_json; 652 BasicVariantType v = true; 653 EXPECT_FALSE(matchProbe(j, v)); 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 690 TEST(MatchProbe, doubleNeqEmpty) 691 { 692 nlohmann::json j = R"(-11.0)"_json; 693 BasicVariantType v; 694 EXPECT_FALSE(matchProbe(j, v)); 695 } 696 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 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 } 745 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 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 } 829 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 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 } 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 } 885