Fixed assignment of JsonDocument to JsonVariant (issue #1023)

This commit is contained in:
Benoit Blanchon
2019-06-25 08:56:14 +02:00
parent a0a451195b
commit 2507ee2e56
4 changed files with 26 additions and 0 deletions

View File

@ -108,3 +108,19 @@ TEST_CASE("JsonVariant with not enough memory") {
REQUIRE(v.isNull());
}
}
TEST_CASE("JsonVariant::set(DynamicJsonDocument)") {
DynamicJsonDocument doc1(1024);
doc1["hello"] = "world";
DynamicJsonDocument doc2(1024);
JsonVariant v = doc2.to<JsonVariant>();
// Should copy the doc
v.set(doc1);
doc1.clear();
std::string json;
serializeJson(doc2, json);
REQUIRE(json == "{\"hello\":\"world\"}");
}