2017-01-06 21:07:34 +01:00
|
|
|
// Copyright Benoit Blanchon 2014-2017
|
2014-12-20 15:16:06 +01:00
|
|
|
// MIT License
|
|
|
|
//
|
|
|
|
// Arduino JSON library
|
2017-03-25 22:05:06 +01:00
|
|
|
// https://bblanchon.github.io/ArduinoJson/
|
2016-01-07 22:35:12 +01:00
|
|
|
// If you like this project, please add a star!
|
2014-12-20 15:16:06 +01:00
|
|
|
|
|
|
|
#include <ArduinoJson.h>
|
2017-04-18 18:22:24 +02:00
|
|
|
#include <catch.hpp>
|
2014-12-20 15:16:06 +01:00
|
|
|
|
2017-04-18 18:22:24 +02:00
|
|
|
TEST_CASE("DynamicJsonBuffer::createObject()") {
|
2014-12-20 15:16:06 +01:00
|
|
|
DynamicJsonBuffer json;
|
|
|
|
|
|
|
|
JsonObject &obj = json.createObject();
|
2017-04-18 18:22:24 +02:00
|
|
|
REQUIRE(JSON_OBJECT_SIZE(0) == json.size());
|
2014-12-20 15:16:06 +01:00
|
|
|
|
2015-05-23 15:32:50 +02:00
|
|
|
obj["hello"] = 1;
|
2017-04-18 18:22:24 +02:00
|
|
|
REQUIRE(JSON_OBJECT_SIZE(1) == json.size());
|
2014-12-20 15:16:06 +01:00
|
|
|
|
2015-05-23 15:32:50 +02:00
|
|
|
obj["world"] = 2;
|
2017-04-18 18:22:24 +02:00
|
|
|
REQUIRE(JSON_OBJECT_SIZE(2) == json.size());
|
2014-12-20 15:16:06 +01:00
|
|
|
|
2015-05-23 15:32:50 +02:00
|
|
|
obj["world"] = 3; // <- same key, should not grow
|
2017-04-18 18:22:24 +02:00
|
|
|
REQUIRE(JSON_OBJECT_SIZE(2) == json.size());
|
2014-12-20 15:16:06 +01:00
|
|
|
}
|