Support ElementProxy and MemberProxy in JsonDocument's constructor

This commit is contained in:
Benoit Blanchon
2024-05-15 09:33:30 +02:00
parent 1c5e5db071
commit aeb30ef307
3 changed files with 29 additions and 9 deletions

View File

@ -126,4 +126,22 @@ TEST_CASE("JsonDocument constructor") {
REQUIRE(doc2.as<std::string>() == "hello");
}
SECTION("JsonDocument(ElementProxy)") {
JsonDocument doc1;
deserializeJson(doc1, "[\"hello\",\"world\"]");
JsonDocument doc2(doc1[1]);
REQUIRE(doc2.as<std::string>() == "world");
}
SECTION("JsonDocument(MemberProxy)") {
JsonDocument doc1;
deserializeJson(doc1, "{\"hello\":\"world\"}");
JsonDocument doc2(doc1["hello"]);
REQUIRE(doc2.as<std::string>() == "world");
}
}