Files
ArduinoJson/tests/JsonObjectTests.cpp

42 lines
942 B
C++
Raw Normal View History

#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"]);
}