Return JsonArray and JsonObject by value (closes #309)

This commit is contained in:
Benoit Blanchon
2018-07-02 09:35:21 +02:00
parent 4fe2b1100e
commit b105e6f7c4
93 changed files with 983 additions and 1091 deletions

View File

@ -6,7 +6,7 @@
#include <catch.hpp>
#include <string>
void check(const JsonObject &obj, const std::string expected) {
void check(const JsonObject obj, const std::string expected) {
char json[256];
size_t actualLen = serializeJsonPretty(obj, json);
@ -19,7 +19,7 @@ void check(const JsonObject &obj, const std::string expected) {
TEST_CASE("serializeJsonPretty(JsonObject)") {
DynamicJsonDocument doc;
JsonObject &obj = doc.to<JsonObject>();
JsonObject obj = doc.to<JsonObject>();
SECTION("EmptyObject") {
check(obj, "{}");
@ -57,10 +57,10 @@ TEST_CASE("serializeJsonPretty(JsonObject)") {
}
SECTION("NestedContainers") {
JsonObject &nested1 = obj.createNestedObject("key1");
JsonObject nested1 = obj.createNestedObject("key1");
nested1["a"] = 1;
JsonArray &nested2 = obj.createNestedArray("key2");
JsonArray nested2 = obj.createNestedArray("key2");
nested2.add(2);
check(obj,