Formated code with clang-format

This commit is contained in:
Benoit Blanchon
2014-10-23 19:54:00 +02:00
parent 888fdc1d54
commit 9175046f35
52 changed files with 2002 additions and 2638 deletions

View File

@ -11,84 +11,68 @@
using namespace ArduinoJson;
class JsonArray_PrettyPrintTo_Tests : public testing::Test
{
class JsonArray_PrettyPrintTo_Tests : public testing::Test {
protected:
JsonArray array;
StaticJsonBuffer<30> json;
JsonArray array;
StaticJsonBuffer<30> json;
virtual void SetUp()
{
array = json.createArray();
}
virtual void SetUp() { array = json.createArray(); }
void outputMustBe(const char* expected)
{
size_t n = array.prettyPrintTo(buffer, sizeof(buffer));
EXPECT_STREQ(expected, buffer);
EXPECT_EQ(strlen(expected), n);
}
void outputMustBe(const char *expected) {
size_t n = array.prettyPrintTo(buffer, sizeof(buffer));
EXPECT_STREQ(expected, buffer);
EXPECT_EQ(strlen(expected), n);
}
private:
char buffer[256];
char buffer[256];
};
TEST_F(JsonArray_PrettyPrintTo_Tests, Empty)
{
outputMustBe("[]");
TEST_F(JsonArray_PrettyPrintTo_Tests, Empty) { outputMustBe("[]"); }
TEST_F(JsonArray_PrettyPrintTo_Tests, OneElement) {
array.add(1);
outputMustBe("[\r\n"
" 1\r\n"
"]");
}
TEST_F(JsonArray_PrettyPrintTo_Tests, OneElement)
{
array.add(1);
TEST_F(JsonArray_PrettyPrintTo_Tests, TwoElements) {
array.add(1);
array.add(2);
outputMustBe(
"[\r\n"
" 1\r\n"
"]");
outputMustBe("[\r\n"
" 1,\r\n"
" 2\r\n"
"]");
}
TEST_F(JsonArray_PrettyPrintTo_Tests, TwoElements)
{
array.add(1);
array.add(2);
TEST_F(JsonArray_PrettyPrintTo_Tests, EmptyNestedArrays) {
array.createNestedArray();
array.createNestedArray();
outputMustBe(
"[\r\n"
" 1,\r\n"
" 2\r\n"
"]");
outputMustBe("[\r\n"
" [],\r\n"
" []\r\n"
"]");
}
TEST_F(JsonArray_PrettyPrintTo_Tests, EmptyNestedArrays)
{
array.createNestedArray();
array.createNestedArray();
TEST_F(JsonArray_PrettyPrintTo_Tests, NestedArrays) {
JsonArray nested1 = array.createNestedArray();
nested1.add(1);
nested1.add(2);
outputMustBe(
"[\r\n"
" [],\r\n"
" []\r\n"
"]");
}
JsonObject nested2 = array.createNestedObject();
nested2["key"] = 3;
TEST_F(JsonArray_PrettyPrintTo_Tests, NestedArrays)
{
JsonArray nested1 = array.createNestedArray();
nested1.add(1);
nested1.add(2);
JsonObject nested2 = array.createNestedObject();
nested2["key"] = 3;
outputMustBe(
"[\r\n"
" [\r\n"
" 1,\r\n"
" 2\r\n"
" ],\r\n"
" {\r\n"
" \"key\": 3\r\n"
" }\r\n"
"]");
outputMustBe("[\r\n"
" [\r\n"
" 1,\r\n"
" 2\r\n"
" ],\r\n"
" {\r\n"
" \"key\": 3\r\n"
" }\r\n"
"]");
}