// ArduinoJson - https://arduinojson.org // Copyright © 2014-2024, Benoit BLANCHON // MIT License #include #include TEST_CASE("Unbound JsonVariant") { JsonVariant variant; SECTION("as()") { CHECK(variant.as() == false); CHECK(variant.as() == 0); CHECK(variant.as() == 0.0f); CHECK(variant.as() == 0); CHECK(variant.as() == "null"); CHECK(variant.as().isNull()); CHECK(variant.as().isNull()); CHECK(variant.as().isNull()); CHECK(variant.as().isNull()); CHECK(variant.as().isNull()); CHECK(variant.as().isNull()); CHECK(variant.as().isNull()); } SECTION("is()") { CHECK_FALSE(variant.is()); CHECK_FALSE(variant.is()); CHECK_FALSE(variant.is()); CHECK_FALSE(variant.is()); CHECK_FALSE(variant.is()); CHECK_FALSE(variant.is()); CHECK_FALSE(variant.is()); CHECK_FALSE(variant.is()); CHECK_FALSE(variant.is()); CHECK_FALSE(variant.is()); CHECK_FALSE(variant.is()); CHECK_FALSE(variant.is()); } SECTION("set()") { CHECK_FALSE(variant.set("42")); CHECK_FALSE(variant.set(42.0)); CHECK_FALSE(variant.set(42L)); CHECK_FALSE(variant.set(42U)); CHECK_FALSE(variant.set(serialized("42"))); CHECK_FALSE(variant.set(serialized(std::string("42")))); CHECK_FALSE(variant.set(true)); } SECTION("add()") { CHECK_FALSE(variant.add("42")); CHECK_FALSE(variant.add(42.0)); CHECK_FALSE(variant.add(42L)); CHECK_FALSE(variant.add(42U)); CHECK_FALSE(variant.add(serialized("42"))); CHECK_FALSE(variant.add(true)); } SECTION("operator[]") { CHECK(variant[0].isNull()); CHECK(variant["key"].isNull()); CHECK_FALSE(variant[0].set(1)); CHECK_FALSE(variant["key"].set(1)); CHECK_FALSE(variant[std::string("key")].set(1)); } SECTION("containsKey()") { CHECK_FALSE(variant.containsKey("hello")); } SECTION("remove()") { variant.remove(0); variant.remove("hello"); } }