mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-15 19:42:12 +02:00
Formated code with clang-format
This commit is contained in:
@ -6,155 +6,130 @@
|
||||
|
||||
using namespace ArduinoJson;
|
||||
|
||||
class JsonObject_Serialization_Tests : public testing::Test
|
||||
{
|
||||
class JsonObject_Serialization_Tests : public testing::Test {
|
||||
protected:
|
||||
virtual void SetUp()
|
||||
{
|
||||
object = json.createObject();
|
||||
}
|
||||
virtual void SetUp() { object = json.createObject(); }
|
||||
|
||||
void outputMustBe(const char* expected)
|
||||
{
|
||||
char actual[256];
|
||||
int result = object.printTo(actual, sizeof(actual));
|
||||
void outputMustBe(const char *expected) {
|
||||
char actual[256];
|
||||
int result = object.printTo(actual, sizeof(actual));
|
||||
|
||||
EXPECT_STREQ(expected, actual);
|
||||
EXPECT_EQ(strlen(expected), result);
|
||||
}
|
||||
EXPECT_STREQ(expected, actual);
|
||||
EXPECT_EQ(strlen(expected), result);
|
||||
}
|
||||
|
||||
JsonObject object;
|
||||
StaticJsonBuffer<5> json;
|
||||
JsonObject object;
|
||||
StaticJsonBuffer<5> json;
|
||||
};
|
||||
|
||||
TEST_F(JsonObject_Serialization_Tests, EmptyObject)
|
||||
{
|
||||
outputMustBe("{}");
|
||||
TEST_F(JsonObject_Serialization_Tests, EmptyObject) { outputMustBe("{}"); }
|
||||
|
||||
TEST_F(JsonObject_Serialization_Tests, OneString) {
|
||||
object["key"] = "value";
|
||||
|
||||
outputMustBe("{\"key\":\"value\"}");
|
||||
}
|
||||
|
||||
TEST_F(JsonObject_Serialization_Tests, OneString)
|
||||
{
|
||||
object["key"] = "value";
|
||||
TEST_F(JsonObject_Serialization_Tests, TwoStrings) {
|
||||
object["key1"] = "value1";
|
||||
object["key2"] = "value2";
|
||||
|
||||
outputMustBe("{\"key\":\"value\"}");
|
||||
outputMustBe("{\"key1\":\"value1\",\"key2\":\"value2\"}");
|
||||
}
|
||||
|
||||
TEST_F(JsonObject_Serialization_Tests, TwoStrings)
|
||||
{
|
||||
object["key1"] = "value1";
|
||||
object["key2"] = "value2";
|
||||
TEST_F(JsonObject_Serialization_Tests, RemoveFirst) {
|
||||
object["key1"] = "value1";
|
||||
object["key2"] = "value2";
|
||||
object.remove("key1");
|
||||
|
||||
outputMustBe("{\"key1\":\"value1\",\"key2\":\"value2\"}");
|
||||
outputMustBe("{\"key2\":\"value2\"}");
|
||||
}
|
||||
|
||||
TEST_F(JsonObject_Serialization_Tests, RemoveFirst)
|
||||
{
|
||||
object["key1"] = "value1";
|
||||
object["key2"] = "value2";
|
||||
object.remove("key1");
|
||||
TEST_F(JsonObject_Serialization_Tests, RemoveLast) {
|
||||
object["key1"] = "value1";
|
||||
object["key2"] = "value2";
|
||||
object.remove("key2");
|
||||
|
||||
outputMustBe("{\"key2\":\"value2\"}");
|
||||
outputMustBe("{\"key1\":\"value1\"}");
|
||||
}
|
||||
|
||||
TEST_F(JsonObject_Serialization_Tests, RemoveLast)
|
||||
{
|
||||
object["key1"] = "value1";
|
||||
object["key2"] = "value2";
|
||||
object.remove("key2");
|
||||
TEST_F(JsonObject_Serialization_Tests, RemoveUnexistingKey) {
|
||||
object["key1"] = "value1";
|
||||
object["key2"] = "value2";
|
||||
object.remove("key3");
|
||||
|
||||
outputMustBe("{\"key1\":\"value1\"}");
|
||||
outputMustBe("{\"key1\":\"value1\",\"key2\":\"value2\"}");
|
||||
}
|
||||
|
||||
TEST_F(JsonObject_Serialization_Tests, RemoveUnexistingKey)
|
||||
{
|
||||
object["key1"] = "value1";
|
||||
object["key2"] = "value2";
|
||||
object.remove("key3");
|
||||
TEST_F(JsonObject_Serialization_Tests, ReplaceExistingKey) {
|
||||
object["key"] = "value1";
|
||||
object["key"] = "value2";
|
||||
|
||||
outputMustBe("{\"key1\":\"value1\",\"key2\":\"value2\"}");
|
||||
outputMustBe("{\"key\":\"value2\"}");
|
||||
}
|
||||
|
||||
TEST_F(JsonObject_Serialization_Tests, ReplaceExistingKey)
|
||||
{
|
||||
object["key"] = "value1";
|
||||
object["key"] = "value2";
|
||||
TEST_F(JsonObject_Serialization_Tests, OneStringOverCapacity) {
|
||||
object["key1"] = "value1";
|
||||
object["key2"] = "value2";
|
||||
object["key3"] = "value3";
|
||||
|
||||
outputMustBe("{\"key\":\"value2\"}");
|
||||
outputMustBe("{\"key1\":\"value1\",\"key2\":\"value2\"}");
|
||||
}
|
||||
|
||||
TEST_F(JsonObject_Serialization_Tests, OneStringOverCapacity)
|
||||
{
|
||||
object["key1"] = "value1";
|
||||
object["key2"] = "value2";
|
||||
object["key3"] = "value3";
|
||||
|
||||
outputMustBe("{\"key1\":\"value1\",\"key2\":\"value2\"}");
|
||||
TEST_F(JsonObject_Serialization_Tests, OneInteger) {
|
||||
object["key"] = 1;
|
||||
outputMustBe("{\"key\":1}");
|
||||
}
|
||||
|
||||
TEST_F(JsonObject_Serialization_Tests, OneInteger)
|
||||
{
|
||||
object["key"] = 1;
|
||||
outputMustBe("{\"key\":1}");
|
||||
TEST_F(JsonObject_Serialization_Tests, OneDoubleFourDigits) {
|
||||
object["key"].set(3.14159265358979323846, 4);
|
||||
outputMustBe("{\"key\":3.1416}");
|
||||
}
|
||||
|
||||
TEST_F(JsonObject_Serialization_Tests, OneDoubleFourDigits)
|
||||
{
|
||||
object["key"].set(3.14159265358979323846, 4);
|
||||
outputMustBe("{\"key\":3.1416}");
|
||||
TEST_F(JsonObject_Serialization_Tests, OneDoubleDefaultDigits) {
|
||||
object["key"] = 3.14159265358979323846;
|
||||
outputMustBe("{\"key\":3.14}");
|
||||
}
|
||||
|
||||
TEST_F(JsonObject_Serialization_Tests, OneDoubleDefaultDigits)
|
||||
{
|
||||
object["key"] = 3.14159265358979323846;
|
||||
outputMustBe("{\"key\":3.14}");
|
||||
TEST_F(JsonObject_Serialization_Tests, OneNull) {
|
||||
object["key"] = (char *)0;
|
||||
outputMustBe("{\"key\":null}");
|
||||
}
|
||||
|
||||
TEST_F(JsonObject_Serialization_Tests, OneNull)
|
||||
{
|
||||
object["key"] = (char*) 0;
|
||||
outputMustBe("{\"key\":null}");
|
||||
TEST_F(JsonObject_Serialization_Tests, OneTrue) {
|
||||
object["key"] = true;
|
||||
outputMustBe("{\"key\":true}");
|
||||
}
|
||||
|
||||
TEST_F(JsonObject_Serialization_Tests, OneTrue)
|
||||
{
|
||||
object["key"] = true;
|
||||
outputMustBe("{\"key\":true}");
|
||||
TEST_F(JsonObject_Serialization_Tests, OneFalse) {
|
||||
object["key"] = false;
|
||||
outputMustBe("{\"key\":false}");
|
||||
}
|
||||
|
||||
TEST_F(JsonObject_Serialization_Tests, OneFalse)
|
||||
{
|
||||
object["key"] = false;
|
||||
outputMustBe("{\"key\":false}");
|
||||
TEST_F(JsonObject_Serialization_Tests, OneEmptyNestedArrayViaProxy) {
|
||||
JsonArray nestedArray = json.createArray();
|
||||
|
||||
object["key"] = nestedArray;
|
||||
|
||||
outputMustBe("{\"key\":[]}");
|
||||
}
|
||||
|
||||
TEST_F(JsonObject_Serialization_Tests, OneEmptyNestedArrayViaProxy)
|
||||
{
|
||||
JsonArray nestedArray = json.createArray();
|
||||
TEST_F(JsonObject_Serialization_Tests, OneEmptyNestedObjectViaProxy) {
|
||||
JsonObject nestedArray = json.createObject();
|
||||
|
||||
object["key"] = nestedArray;
|
||||
object["key"] = nestedArray;
|
||||
|
||||
outputMustBe("{\"key\":[]}");
|
||||
outputMustBe("{\"key\":{}}");
|
||||
}
|
||||
|
||||
TEST_F(JsonObject_Serialization_Tests, OneEmptyNestedObjectViaProxy)
|
||||
{
|
||||
JsonObject nestedArray = json.createObject();
|
||||
TEST_F(JsonObject_Serialization_Tests, OneEmptyNestedObject) {
|
||||
object.createNestedObject("key");
|
||||
|
||||
object["key"] = nestedArray;
|
||||
|
||||
outputMustBe("{\"key\":{}}");
|
||||
outputMustBe("{\"key\":{}}");
|
||||
}
|
||||
|
||||
TEST_F(JsonObject_Serialization_Tests, OneEmptyNestedObject)
|
||||
{
|
||||
object.createNestedObject("key");
|
||||
TEST_F(JsonObject_Serialization_Tests, OneEmptyNestedArray) {
|
||||
object.createNestedArray("key");
|
||||
|
||||
outputMustBe("{\"key\":{}}");
|
||||
}
|
||||
|
||||
TEST_F(JsonObject_Serialization_Tests, OneEmptyNestedArray)
|
||||
{
|
||||
object.createNestedArray("key");
|
||||
|
||||
outputMustBe("{\"key\":[]}");
|
||||
outputMustBe("{\"key\":[]}");
|
||||
}
|
Reference in New Issue
Block a user