diff --git a/extras/tests/JsonVariant/link.cpp b/extras/tests/JsonVariant/link.cpp index 5e4662d8..6c6ebdb3 100644 --- a/extras/tests/JsonVariant/link.cpp +++ b/extras/tests/JsonVariant/link.cpp @@ -51,21 +51,3 @@ TEST_CASE("JsonVariant::link()") { CHECK(variant.as() == "{\"hello\":\"WORLD!\"}"); } } - -TEST_CASE("Linked document") { - StaticJsonDocument<1024> doc1, doc2; - JsonVariant variant = doc1.to(); - doc2["hello"] = "world"; - variant.link(doc2); - - SECTION("get member") { - CHECK(variant["hello"].as() == "world"); - } - - SECTION("set member") { - // The link is read-only; the following line should have no side effect - variant["tutu"] = "toto"; - - CHECK(doc1.as() == "{\"hello\":\"world\"}"); - } -} diff --git a/extras/tests/JsonVariant/subscript.cpp b/extras/tests/JsonVariant/subscript.cpp index f466cd27..9874819c 100644 --- a/extras/tests/JsonVariant/subscript.cpp +++ b/extras/tests/JsonVariant/subscript.cpp @@ -129,6 +129,26 @@ TEST_CASE("JsonVariant::operator[]") { REQUIRE(std::string("world") == variant[vla]); } #endif + + SECTION("get value from linked object") { + StaticJsonDocument<1024> doc1, doc2; + doc2["hello"] = "world"; + var.link(doc2); + + CHECK(var["hello"].as() == "world"); + } + + SECTION("try to set value to linked object") { + StaticJsonDocument<1024> doc1, doc2; + doc2["hello"] = "world"; + var.link(doc2); + + // The link is read-only; the following line should have no side effect + var["tutu"] = "toto"; + + CHECK(doc.as() == "{\"hello\":\"world\"}"); + CHECK(doc2.as() == "{\"hello\":\"world\"}"); + } } TEST_CASE("JsonVariantConst::operator[]") {