mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-29 10:17:39 +02:00
Test that nested JsonObject can be stored
This commit is contained in:
@ -66,4 +66,16 @@ TEST_F(JsonObjectTests, CanStoreStrings)
|
||||
|
||||
EXPECT_STREQ("h3110", (const char*) object["hello"]);
|
||||
EXPECT_STREQ("w0r1d", (const char*) object["world"]);
|
||||
}
|
||||
|
||||
TEST_F(JsonObjectTests, CanStoreInnerObjects)
|
||||
{
|
||||
JsonObject innerObject1 = json.createObject();
|
||||
JsonObject innerObject2 = json.createObject();
|
||||
|
||||
object["hello"] = innerObject1;
|
||||
object["world"] = innerObject2;
|
||||
|
||||
EXPECT_EQ(innerObject1, (JsonObject) object["hello"]);
|
||||
EXPECT_EQ(innerObject2, (JsonObject) object["world"]);
|
||||
}
|
58
tests/JsonValueTests.cpp
Normal file
58
tests/JsonValueTests.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <StaticJsonBuffer.h>
|
||||
#include <JsonValue.h>
|
||||
|
||||
class JsonValueTests : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
virtual void SetUp()
|
||||
{
|
||||
jsonValue = json.createValue();
|
||||
}
|
||||
|
||||
StaticJsonBuffer<42> json;
|
||||
JsonValue jsonValue;
|
||||
};
|
||||
|
||||
|
||||
TEST_F(JsonValueTests, CanStoreInteger)
|
||||
{
|
||||
jsonValue = 123;
|
||||
|
||||
EXPECT_EQ(123, (int) jsonValue);
|
||||
}
|
||||
|
||||
TEST_F(JsonValueTests, CanStoreDouble)
|
||||
{
|
||||
jsonValue = 123.45;
|
||||
|
||||
EXPECT_EQ(123.45, (double) jsonValue);
|
||||
}
|
||||
|
||||
TEST_F(JsonValueTests, CanStoreTrue)
|
||||
{
|
||||
jsonValue = true;
|
||||
EXPECT_TRUE((bool) jsonValue);
|
||||
}
|
||||
|
||||
TEST_F(JsonValueTests, CanStoreFalse)
|
||||
{
|
||||
jsonValue = false;
|
||||
EXPECT_FALSE((bool) jsonValue);
|
||||
}
|
||||
|
||||
TEST_F(JsonValueTests, CanStoreString)
|
||||
{
|
||||
jsonValue = "hello";
|
||||
|
||||
EXPECT_STREQ("hello", (const char*) jsonValue);
|
||||
}
|
||||
|
||||
TEST_F(JsonValueTests, CanStoreObject)
|
||||
{
|
||||
JsonObject innerObject1 = json.createObject();
|
||||
|
||||
jsonValue = innerObject1;
|
||||
|
||||
EXPECT_EQ(innerObject1, (JsonObject) jsonValue);
|
||||
}
|
@ -86,6 +86,7 @@
|
||||
<ClCompile Include="..\third-party\gtest-1.7.0\src\gtest-all.cc" />
|
||||
<ClCompile Include="..\third-party\gtest-1.7.0\src\gtest_main.cc" />
|
||||
<ClCompile Include="JsonObjectTests.cpp" />
|
||||
<ClCompile Include="JsonValueTests.cpp" />
|
||||
<ClCompile Include="StaticJsonBufferTests.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -30,5 +30,8 @@
|
||||
<ClCompile Include="JsonObjectTests.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="JsonValueTests.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
Reference in New Issue
Block a user