Support ElementProxy and MemberProxy in JsonDocument's constructor

This commit is contained in:
Benoit Blanchon committed 2024-05-15 13:37:33 +02:00
1 parent 1c5e5db071
commit aeb30ef307
3 files changed
+29 -9

No files matched your search

+18
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");
}
}