10000 Test object allocation with DynamicJsonBuffer · littlestrange/ArduinoJson@d855b0f · GitHub
[go: up one dir, main page]

Skip to content

Commit d855b0f

Browse files
committed
Test object allocation with DynamicJsonBuffer
1 parent c726506 commit d855b0f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright Benoit Blanchon 2014
2+
// MIT License
3+
//
4+
// Arduino JSON library
5+
// https://github.com/bblanchon/ArduinoJson
6+
7+
#include <gtest/gtest.h>
8+
#include <ArduinoJson.h>
9+
10+
TEST(DynamicJsonBuffer_Object_Tests, GrowsWithObject) {
11+
DynamicJsonBuffer json;
12+
13+
JsonObject &obj = json.createObject();
14+
ASSERT_EQ(JSON_OBJECT_SIZE(0), json.size());
15+
16+
obj["hello"];
17+
ASSERT_EQ(JSON_OBJECT_SIZE(1), json.size());
18+
19+
obj["world"];
20+
ASSERT_EQ(JSON_OBJECT_SIZE(2), json.size());
21+
22+
obj["world"]; // <- same value, should not grow
23+
ASSERT_EQ(JSON_OBJECT_SIZE(2), json.size());
24+
}

0 commit comments

Comments
 (0)
0