JsonVariant automatically promotes to JsonObject or JsonArray on write

This commit is contained in:
Benoit Blanchon
2019-01-29 14:09:09 +01:00
parent 5aea1363cc
commit 6f55d1e58f
53 changed files with 1197 additions and 541 deletions

View File

@ -21,6 +21,11 @@ TEST_CASE("JsonDocument::operator[]") {
REQUIRE(doc[std::string("hello")] == "world");
REQUIRE(cdoc[std::string("hello")] == "world");
}
SECTION("supports operator|") {
REQUIRE((doc["hello"] | "nope") == std::string("world"));
REQUIRE((doc["world"] | "nope") == std::string("nope"));
}
}
SECTION("array") {
@ -30,3 +35,11 @@ TEST_CASE("JsonDocument::operator[]") {
REQUIRE(cdoc[1] == "world");
}
}
TEST_CASE("JsonDocument automatically promotes to object") {
DynamicJsonDocument doc(4096);
doc["one"]["two"]["three"] = 4;
REQUIRE(doc["one"]["two"]["three"] == 4);
}