From 8071434515c06185b32d168707c012054eb590eb Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Fri, 24 Oct 2014 00:08:25 +0200 Subject: [PATCH] Fixed many cpplint warnings --- include/ArduinoJson/JsonBuffer.hpp | 2 +- include/ArduinoJson/JsonValue.hpp | 8 ++++---- src/Internals/JsonParser.cpp | 4 ++-- test/JsonArray_PrintTo_Tests.cpp | 2 +- test/JsonObject_Container_Tests.cpp | 24 ++++++++++++------------ test/JsonObject_Serialization_Tests.cpp | 2 +- test/JsonValueTests.cpp | 24 ++++++++++++------------ 7 files changed, 33 insertions(+), 33 deletions(-) diff --git a/include/ArduinoJson/JsonBuffer.hpp b/include/ArduinoJson/JsonBuffer.hpp index 26d3198f..6ad069fa 100644 --- a/include/ArduinoJson/JsonBuffer.hpp +++ b/include/ArduinoJson/JsonBuffer.hpp @@ -20,7 +20,7 @@ class JsonBuffer { friend class Internals::JsonParser; public: - virtual ~JsonBuffer(){}; + virtual ~JsonBuffer() {} JsonArray createArray() { return JsonArray(createArrayNode()); } diff --git a/include/ArduinoJson/JsonValue.hpp b/include/ArduinoJson/JsonValue.hpp index 1e7fd8d4..f90ba0d3 100644 --- a/include/ArduinoJson/JsonValue.hpp +++ b/include/ArduinoJson/JsonValue.hpp @@ -19,10 +19,10 @@ class JsonValue : public Internals::JsonNodeWrapper { explicit JsonValue(Internals::JsonNode *node) : JsonNodeWrapper(node) {} - void operator=(bool); - void operator=(const char *); - void operator=(double x) { set(x, 2); } - void operator=(int); + void operator=(bool value); + void operator=(const char *value); + void operator=(double value) { set(value, 2); } + void operator=(int value); void operator=(const JsonValue &value) { duplicate(value); } void operator=(const Internals::JsonNodeWrapper &object) { duplicate(object); diff --git a/src/Internals/JsonParser.cpp b/src/Internals/JsonParser.cpp index 308de6cf..90a970d5 100644 --- a/src/Internals/JsonParser.cpp +++ b/src/Internals/JsonParser.cpp @@ -102,8 +102,8 @@ JsonNode *JsonParser::parseNumber() { char *endOfLong; long longValue = strtol(_ptr, &endOfLong, 10); - if (*endOfLong == '.') // stopped on a decimal separator - { + if (*endOfLong == '.') { + // stopped on a decimal separator double value = strtod(_ptr, &_ptr); int decimals = _ptr - endOfLong - 1; return _buffer->createDoubleNode(value, decimals); diff --git a/test/JsonArray_PrintTo_Tests.cpp b/test/JsonArray_PrintTo_Tests.cpp index 24ff56c4..7a0974e7 100644 --- a/test/JsonArray_PrintTo_Tests.cpp +++ b/test/JsonArray_PrintTo_Tests.cpp @@ -31,7 +31,7 @@ class JsonArray_PrintTo_Tests : public testing::Test { TEST_F(JsonArray_PrintTo_Tests, Empty) { outputMustBe("[]"); } TEST_F(JsonArray_PrintTo_Tests, Null) { - array.add((char *)0); + array.add(static_cast(0)); outputMustBe("[null]"); } diff --git a/test/JsonObject_Container_Tests.cpp b/test/JsonObject_Container_Tests.cpp index bd64183b..542dae22 100644 --- a/test/JsonObject_Container_Tests.cpp +++ b/test/JsonObject_Container_Tests.cpp @@ -63,32 +63,32 @@ TEST_F(JsonObject_Container_Tests, CanStoreIntegers) { object["hello"] = 123; object["world"] = 456; - EXPECT_EQ(123, (int)object["hello"]); - EXPECT_EQ(456, (int)object["world"]); + EXPECT_EQ(123, object["hello"].as()); + EXPECT_EQ(456, object["world"].as()); } TEST_F(JsonObject_Container_Tests, CanStoreDoubles) { object["hello"] = 123.45; object["world"] = 456.78; - EXPECT_EQ(123.45, (double)object["hello"]); - EXPECT_EQ(456.78, (double)object["world"]); + EXPECT_EQ(123.45, object["hello"].as()); + EXPECT_EQ(456.78, object["world"].as()); } TEST_F(JsonObject_Container_Tests, CanStoreBooleans) { object["hello"] = true; object["world"] = false; - EXPECT_TRUE((bool)object["hello"]); - EXPECT_FALSE((bool)object["world"]); + EXPECT_TRUE(object["hello"].as()); + EXPECT_FALSE(object["world"].as()); } TEST_F(JsonObject_Container_Tests, CanStoreStrings) { object["hello"] = "h3110"; object["world"] = "w0r1d"; - EXPECT_STREQ("h3110", (const char *)object["hello"]); - EXPECT_STREQ("w0r1d", (const char *)object["world"]); + EXPECT_STREQ("h3110", object["hello"].as()); + EXPECT_STREQ("w0r1d", object["world"].as()); } TEST_F(JsonObject_Container_Tests, CanStoreInnerArrays) { @@ -98,8 +98,8 @@ TEST_F(JsonObject_Container_Tests, CanStoreInnerArrays) { object["hello"] = innerarray1; object["world"] = innerarray2; - EXPECT_EQ(innerarray1, (JsonArray)object["hello"]); - EXPECT_EQ(innerarray2, (JsonArray)object["world"]); + EXPECT_EQ(innerarray1, object["hello"].as()); + EXPECT_EQ(innerarray2, object["world"].as()); } TEST_F(JsonObject_Container_Tests, CanStoreInnerObjects) { @@ -109,6 +109,6 @@ TEST_F(JsonObject_Container_Tests, CanStoreInnerObjects) { object["hello"] = innerObject1; object["world"] = innerObject2; - EXPECT_EQ(innerObject1, (JsonObject)object["hello"]); - EXPECT_EQ(innerObject2, (JsonObject)object["world"]); + EXPECT_EQ(innerObject1, object["hello"].as()); + EXPECT_EQ(innerObject2, object["world"].as()); } diff --git a/test/JsonObject_Serialization_Tests.cpp b/test/JsonObject_Serialization_Tests.cpp index 1e4dc9c5..1ea4b0d9 100644 --- a/test/JsonObject_Serialization_Tests.cpp +++ b/test/JsonObject_Serialization_Tests.cpp @@ -98,7 +98,7 @@ TEST_F(JsonObject_Serialization_Tests, OneDoubleDefaultDigits) { } TEST_F(JsonObject_Serialization_Tests, OneNull) { - object["key"] = (char *)0; + object["key"] = static_cast(0); outputMustBe("{\"key\":null}"); } diff --git a/test/JsonValueTests.cpp b/test/JsonValueTests.cpp index f386cacf..f05ceaf9 100644 --- a/test/JsonValueTests.cpp +++ b/test/JsonValueTests.cpp @@ -25,29 +25,29 @@ class JsonValueTests : public ::testing::Test { TEST_F(JsonValueTests, CanStoreInteger) { jsonValue1 = 123; - EXPECT_EQ(123, (int)jsonValue1); + EXPECT_EQ(123, jsonValue1.as()); } TEST_F(JsonValueTests, CanStoreDouble) { jsonValue1 = 123.45; - EXPECT_EQ(123.45, (double)jsonValue1); + EXPECT_EQ(123.45, jsonValue1.as()); } TEST_F(JsonValueTests, CanStoreTrue) { jsonValue1 = true; - EXPECT_TRUE((bool)jsonValue1); + EXPECT_TRUE(jsonValue1.as()); } TEST_F(JsonValueTests, CanStoreFalse) { jsonValue1 = false; - EXPECT_FALSE((bool)jsonValue1); + EXPECT_FALSE(jsonValue1.as()); } TEST_F(JsonValueTests, CanStoreString) { jsonValue1 = "hello"; - EXPECT_STREQ("hello", (const char *)jsonValue1); + EXPECT_STREQ("hello", jsonValue1.as()); } TEST_F(JsonValueTests, CanStoreObject) { @@ -55,7 +55,7 @@ TEST_F(JsonValueTests, CanStoreObject) { jsonValue1 = innerObject1; - EXPECT_EQ(innerObject1, (JsonObject)jsonValue1); + EXPECT_EQ(innerObject1, jsonValue1.as()); } TEST_F(JsonValueTests, IntegersAreCopiedByValue) { @@ -63,7 +63,7 @@ TEST_F(JsonValueTests, IntegersAreCopiedByValue) { jsonValue2 = jsonValue1; jsonValue1 = 456; - EXPECT_EQ(123, (int)jsonValue2); + EXPECT_EQ(123, jsonValue2.as()); } TEST_F(JsonValueTests, DoublesAreCopiedByValue) { @@ -71,7 +71,7 @@ TEST_F(JsonValueTests, DoublesAreCopiedByValue) { jsonValue2 = jsonValue1; jsonValue1 = 456.78; - EXPECT_EQ(123.45, (double)jsonValue2); + EXPECT_EQ(123.45, jsonValue2.as()); } TEST_F(JsonValueTests, BooleansAreCopiedByValue) { @@ -79,7 +79,7 @@ TEST_F(JsonValueTests, BooleansAreCopiedByValue) { jsonValue2 = jsonValue1; jsonValue1 = false; - EXPECT_TRUE((bool)jsonValue2); + EXPECT_TRUE(jsonValue2.as()); } TEST_F(JsonValueTests, StringsAreCopiedByValue) { @@ -87,7 +87,7 @@ TEST_F(JsonValueTests, StringsAreCopiedByValue) { jsonValue2 = jsonValue1; jsonValue1 = "world"; - EXPECT_STREQ("hello", (const char *)jsonValue2); + EXPECT_STREQ("hello", jsonValue2.as()); } TEST_F(JsonValueTests, ObjectsAreCopiedByReference) { @@ -97,7 +97,7 @@ TEST_F(JsonValueTests, ObjectsAreCopiedByReference) { object["hello"] = "world"; - EXPECT_EQ(1, ((JsonObject)jsonValue1).size()); + EXPECT_EQ(1, jsonValue1.as().size()); } TEST_F(JsonValueTests, ArraysAreCopiedByReference) { @@ -107,5 +107,5 @@ TEST_F(JsonValueTests, ArraysAreCopiedByReference) { array.add("world"); - EXPECT_EQ(1, ((JsonObject)jsonValue1).size()); + EXPECT_EQ(1, jsonValue1.as().size()); }