// ArduinoJson - https://arduinojson.org // Copyright © 2014-2022, Benoit BLANCHON // MIT License #define ARDUINOJSON_DEPRECATED(msg) // nothing #include #include TEST_CASE("Deprecated features") { StaticJsonDocument<256> doc; const char* s = "hello"; doc["s"] = s; doc["c"] = 42; doc["a"].add(s); doc["a"].add(42); SECTION("JsonVariant::add(char)") { JsonVariant v = doc.to(); v.add('*'); REQUIRE(v[0] == 42); } SECTION("JsonVariant::as()") { JsonVariant v = doc["s"]; REQUIRE(v.as() == s); } SECTION("JsonVariant::as()") { JsonVariant v = doc["c"]; REQUIRE(v.as() == '*'); } SECTION("JsonVariant::is()") { JsonVariant v = doc["s"]; REQUIRE(v.is() == true); } SECTION("JsonVariant::is()") { JsonVariant v = doc["c"]; REQUIRE(v.is() == true); } SECTION("JsonVariant::set(char)") { JsonVariant v = doc.to(); v.set('*'); REQUIRE(v.as() == 42); } SECTION("JsonVariantConst::as()") { JsonVariantConst v = doc["s"]; REQUIRE(v.as() == s); } SECTION("JsonVariantConst::as()") { JsonVariantConst v = doc["c"]; REQUIRE(v.as() == '*'); } SECTION("JsonVariantConst::is()") { JsonVariantConst v = doc["s"]; REQUIRE(v.is() == true); } SECTION("JsonVariantConst::is()") { JsonVariantConst v = doc["c"]; REQUIRE(v.is() == true); } SECTION("MemberProxy::as()") { REQUIRE(doc["s"].as() == s); } SECTION("MemberProxy::as()") { REQUIRE(doc["c"].as() == '*'); } SECTION("MemberProxy::as()") { doc["x"].set('*'); REQUIRE(doc["x"] == 42); } SECTION("MemberProxy::is()") { REQUIRE(doc["s"].is() == true); REQUIRE(doc["c"].is() == false); } SECTION("MemberProxy::is()") { REQUIRE(doc["c"].is() == true); REQUIRE(doc["s"].is() == false); } SECTION("ElementProxy::as()") { REQUIRE(doc["a"][0].as() == s); } SECTION("ElementProxy::as()") { REQUIRE(doc["a"][1].as() == '*'); } SECTION("ElementProxy::as()") { doc["a"][0].set('*'); REQUIRE(doc["a"][0] == 42); } SECTION("ElementProxy::is()") { REQUIRE(doc["a"][0].is() == true); REQUIRE(doc["a"][1].is() == false); } SECTION("ElementProxy::is()") { REQUIRE(doc["a"][1].is() == true); REQUIRE(doc["a"][0].is() == false); } }