mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-01 00:38:27 +01:00
Support JsonDocument*
This commit is contained in:
@@ -43,4 +43,24 @@ TEST_CASE("JsonVariant::add()") {
|
||||
|
||||
REQUIRE(var.as<std::string>() == "{\"val\":123}");
|
||||
}
|
||||
|
||||
SECTION("add JsonDocument to new variant") {
|
||||
StaticJsonDocument<128> doc2;
|
||||
doc2["hello"] = "world";
|
||||
|
||||
var.add(doc2);
|
||||
|
||||
CHECK(var.as<std::string>() == "[{\"hello\":\"world\"}]");
|
||||
CHECK(var.memoryUsage() == JSON_ARRAY_SIZE(1) + JSON_OBJECT_SIZE(1));
|
||||
}
|
||||
|
||||
SECTION("add JsonDocument* to new variant") {
|
||||
StaticJsonDocument<128> doc2;
|
||||
doc2["hello"] = "world";
|
||||
|
||||
var.add(&doc2);
|
||||
|
||||
CHECK(var.as<std::string>() == "[{\"hello\":\"world\"}]");
|
||||
CHECK(var.memoryUsage() == JSON_ARRAY_SIZE(1));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user