Fixed many cpplint warnings

This commit is contained in:
Benoit Blanchon
2014-10-24 00:08:25 +02:00
parent 7f22a1ab39
commit 8071434515
7 changed files with 33 additions and 33 deletions

View File

@ -20,7 +20,7 @@ class JsonBuffer {
friend class Internals::JsonParser; friend class Internals::JsonParser;
public: public:
virtual ~JsonBuffer(){}; virtual ~JsonBuffer() {}
JsonArray createArray() { return JsonArray(createArrayNode()); } JsonArray createArray() { return JsonArray(createArrayNode()); }

View File

@ -19,10 +19,10 @@ class JsonValue : public Internals::JsonNodeWrapper {
explicit JsonValue(Internals::JsonNode *node) : JsonNodeWrapper(node) {} explicit JsonValue(Internals::JsonNode *node) : JsonNodeWrapper(node) {}
void operator=(bool); void operator=(bool value);
void operator=(const char *); void operator=(const char *value);
void operator=(double x) { set(x, 2); } void operator=(double value) { set(value, 2); }
void operator=(int); void operator=(int value);
void operator=(const JsonValue &value) { duplicate(value); } void operator=(const JsonValue &value) { duplicate(value); }
void operator=(const Internals::JsonNodeWrapper &object) { void operator=(const Internals::JsonNodeWrapper &object) {
duplicate(object); duplicate(object);

View File

@ -102,8 +102,8 @@ JsonNode *JsonParser::parseNumber() {
char *endOfLong; char *endOfLong;
long longValue = strtol(_ptr, &endOfLong, 10); 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); double value = strtod(_ptr, &_ptr);
int decimals = _ptr - endOfLong - 1; int decimals = _ptr - endOfLong - 1;
return _buffer->createDoubleNode(value, decimals); return _buffer->createDoubleNode(value, decimals);

View File

@ -31,7 +31,7 @@ class JsonArray_PrintTo_Tests : public testing::Test {
TEST_F(JsonArray_PrintTo_Tests, Empty) { outputMustBe("[]"); } TEST_F(JsonArray_PrintTo_Tests, Empty) { outputMustBe("[]"); }
TEST_F(JsonArray_PrintTo_Tests, Null) { TEST_F(JsonArray_PrintTo_Tests, Null) {
array.add((char *)0); array.add(static_cast<char *>(0));
outputMustBe("[null]"); outputMustBe("[null]");
} }

View File

@ -63,32 +63,32 @@ TEST_F(JsonObject_Container_Tests, CanStoreIntegers) {
object["hello"] = 123; object["hello"] = 123;
object["world"] = 456; object["world"] = 456;
EXPECT_EQ(123, (int)object["hello"]); EXPECT_EQ(123, object["hello"].as<int>());
EXPECT_EQ(456, (int)object["world"]); EXPECT_EQ(456, object["world"].as<int>());
} }
TEST_F(JsonObject_Container_Tests, CanStoreDoubles) { TEST_F(JsonObject_Container_Tests, CanStoreDoubles) {
object["hello"] = 123.45; object["hello"] = 123.45;
object["world"] = 456.78; object["world"] = 456.78;
EXPECT_EQ(123.45, (double)object["hello"]); EXPECT_EQ(123.45, object["hello"].as<double>());
EXPECT_EQ(456.78, (double)object["world"]); EXPECT_EQ(456.78, object["world"].as<double>());
} }
TEST_F(JsonObject_Container_Tests, CanStoreBooleans) { TEST_F(JsonObject_Container_Tests, CanStoreBooleans) {
object["hello"] = true; object["hello"] = true;
object["world"] = false; object["world"] = false;
EXPECT_TRUE((bool)object["hello"]); EXPECT_TRUE(object["hello"].as<bool>());
EXPECT_FALSE((bool)object["world"]); EXPECT_FALSE(object["world"].as<bool>());
} }
TEST_F(JsonObject_Container_Tests, CanStoreStrings) { TEST_F(JsonObject_Container_Tests, CanStoreStrings) {
object["hello"] = "h3110"; object["hello"] = "h3110";
object["world"] = "w0r1d"; object["world"] = "w0r1d";
EXPECT_STREQ("h3110", (const char *)object["hello"]); EXPECT_STREQ("h3110", object["hello"].as<const char*>());
EXPECT_STREQ("w0r1d", (const char *)object["world"]); EXPECT_STREQ("w0r1d", object["world"].as<const char*>());
} }
TEST_F(JsonObject_Container_Tests, CanStoreInnerArrays) { TEST_F(JsonObject_Container_Tests, CanStoreInnerArrays) {
@ -98,8 +98,8 @@ TEST_F(JsonObject_Container_Tests, CanStoreInnerArrays) {
object["hello"] = innerarray1; object["hello"] = innerarray1;
object["world"] = innerarray2; object["world"] = innerarray2;
EXPECT_EQ(innerarray1, (JsonArray)object["hello"]); EXPECT_EQ(innerarray1, object["hello"].as<JsonArray>());
EXPECT_EQ(innerarray2, (JsonArray)object["world"]); EXPECT_EQ(innerarray2, object["world"].as<JsonArray>());
} }
TEST_F(JsonObject_Container_Tests, CanStoreInnerObjects) { TEST_F(JsonObject_Container_Tests, CanStoreInnerObjects) {
@ -109,6 +109,6 @@ TEST_F(JsonObject_Container_Tests, CanStoreInnerObjects) {
object["hello"] = innerObject1; object["hello"] = innerObject1;
object["world"] = innerObject2; object["world"] = innerObject2;
EXPECT_EQ(innerObject1, (JsonObject)object["hello"]); EXPECT_EQ(innerObject1, object["hello"].as<JsonObject>());
EXPECT_EQ(innerObject2, (JsonObject)object["world"]); EXPECT_EQ(innerObject2, object["world"].as<JsonObject>());
} }

View File

@ -98,7 +98,7 @@ TEST_F(JsonObject_Serialization_Tests, OneDoubleDefaultDigits) {
} }
TEST_F(JsonObject_Serialization_Tests, OneNull) { TEST_F(JsonObject_Serialization_Tests, OneNull) {
object["key"] = (char *)0; object["key"] = static_cast<char *>(0);
outputMustBe("{\"key\":null}"); outputMustBe("{\"key\":null}");
} }

View File

@ -25,29 +25,29 @@ class JsonValueTests : public ::testing::Test {
TEST_F(JsonValueTests, CanStoreInteger) { TEST_F(JsonValueTests, CanStoreInteger) {
jsonValue1 = 123; jsonValue1 = 123;
EXPECT_EQ(123, (int)jsonValue1); EXPECT_EQ(123, jsonValue1.as<int>());
} }
TEST_F(JsonValueTests, CanStoreDouble) { TEST_F(JsonValueTests, CanStoreDouble) {
jsonValue1 = 123.45; jsonValue1 = 123.45;
EXPECT_EQ(123.45, (double)jsonValue1); EXPECT_EQ(123.45, jsonValue1.as<double>());
} }
TEST_F(JsonValueTests, CanStoreTrue) { TEST_F(JsonValueTests, CanStoreTrue) {
jsonValue1 = true; jsonValue1 = true;
EXPECT_TRUE((bool)jsonValue1); EXPECT_TRUE(jsonValue1.as<bool>());
} }
TEST_F(JsonValueTests, CanStoreFalse) { TEST_F(JsonValueTests, CanStoreFalse) {
jsonValue1 = false; jsonValue1 = false;
EXPECT_FALSE((bool)jsonValue1); EXPECT_FALSE(jsonValue1.as<bool>());
} }
TEST_F(JsonValueTests, CanStoreString) { TEST_F(JsonValueTests, CanStoreString) {
jsonValue1 = "hello"; jsonValue1 = "hello";
EXPECT_STREQ("hello", (const char *)jsonValue1); EXPECT_STREQ("hello", jsonValue1.as<const char *>());
} }
TEST_F(JsonValueTests, CanStoreObject) { TEST_F(JsonValueTests, CanStoreObject) {
@ -55,7 +55,7 @@ TEST_F(JsonValueTests, CanStoreObject) {
jsonValue1 = innerObject1; jsonValue1 = innerObject1;
EXPECT_EQ(innerObject1, (JsonObject)jsonValue1); EXPECT_EQ(innerObject1, jsonValue1.as<JsonObject>());
} }
TEST_F(JsonValueTests, IntegersAreCopiedByValue) { TEST_F(JsonValueTests, IntegersAreCopiedByValue) {
@ -63,7 +63,7 @@ TEST_F(JsonValueTests, IntegersAreCopiedByValue) {
jsonValue2 = jsonValue1; jsonValue2 = jsonValue1;
jsonValue1 = 456; jsonValue1 = 456;
EXPECT_EQ(123, (int)jsonValue2); EXPECT_EQ(123, jsonValue2.as<int>());
} }
TEST_F(JsonValueTests, DoublesAreCopiedByValue) { TEST_F(JsonValueTests, DoublesAreCopiedByValue) {
@ -71,7 +71,7 @@ TEST_F(JsonValueTests, DoublesAreCopiedByValue) {
jsonValue2 = jsonValue1; jsonValue2 = jsonValue1;
jsonValue1 = 456.78; jsonValue1 = 456.78;
EXPECT_EQ(123.45, (double)jsonValue2); EXPECT_EQ(123.45, jsonValue2.as<double>());
} }
TEST_F(JsonValueTests, BooleansAreCopiedByValue) { TEST_F(JsonValueTests, BooleansAreCopiedByValue) {
@ -79,7 +79,7 @@ TEST_F(JsonValueTests, BooleansAreCopiedByValue) {
jsonValue2 = jsonValue1; jsonValue2 = jsonValue1;
jsonValue1 = false; jsonValue1 = false;
EXPECT_TRUE((bool)jsonValue2); EXPECT_TRUE(jsonValue2.as<bool>());
} }
TEST_F(JsonValueTests, StringsAreCopiedByValue) { TEST_F(JsonValueTests, StringsAreCopiedByValue) {
@ -87,7 +87,7 @@ TEST_F(JsonValueTests, StringsAreCopiedByValue) {
jsonValue2 = jsonValue1; jsonValue2 = jsonValue1;
jsonValue1 = "world"; jsonValue1 = "world";
EXPECT_STREQ("hello", (const char *)jsonValue2); EXPECT_STREQ("hello", jsonValue2.as<const char *>());
} }
TEST_F(JsonValueTests, ObjectsAreCopiedByReference) { TEST_F(JsonValueTests, ObjectsAreCopiedByReference) {
@ -97,7 +97,7 @@ TEST_F(JsonValueTests, ObjectsAreCopiedByReference) {
object["hello"] = "world"; object["hello"] = "world";
EXPECT_EQ(1, ((JsonObject)jsonValue1).size()); EXPECT_EQ(1, jsonValue1.as<JsonObject>().size());
} }
TEST_F(JsonValueTests, ArraysAreCopiedByReference) { TEST_F(JsonValueTests, ArraysAreCopiedByReference) {
@ -107,5 +107,5 @@ TEST_F(JsonValueTests, ArraysAreCopiedByReference) {
array.add("world"); array.add("world");
EXPECT_EQ(1, ((JsonObject)jsonValue1).size()); EXPECT_EQ(1, jsonValue1.as<JsonArray>().size());
} }