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