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