| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #include <gtest/gtest.h>
- #include <StaticJsonBuffer.h>
- #include <JsonValue.h>
- TEST(JsonObjectTests, WhenValueIsAdded_ThenSizeIsIncreasedByOne)
- {
- StaticJsonBuffer<42> json;
- JsonObject object = json.createObject();
- object["hello"];
- EXPECT_EQ(1, object.size());
- object["world"];
- EXPECT_EQ(2, object.size());
- }
- TEST(JsonObjectTests, WhenTheSameValueIsAddedTwice_ThenSizeIsOnlyIncreasedByOne)
- {
- StaticJsonBuffer<42> json;
- JsonObject object = json.createObject();
- object["hello"];
- EXPECT_EQ(1, object.size());
- object["hello"];
- EXPECT_EQ(1, object.size());
- }
- TEST(JsonObjectTests, WhenAnIntegerIsStore_TheSameIntegerIsRetreived)
- {
- StaticJsonBuffer<42> json;
- JsonObject object = json.createObject();
- object["hello"] = 123;
- object["world"] = 456;
- EXPECT_EQ(123, (int) object["hello"]);
- EXPECT_EQ(456, (int) object["world"]);
- }
|