diff --git a/.clang-format b/.clang-format deleted file mode 100644 index 468ceea0..00000000 --- a/.clang-format +++ /dev/null @@ -1 +0,0 @@ -BasedOnStyle: LLVM \ No newline at end of file diff --git a/include/ArduinoJson/Arduino/Print.hpp b/include/ArduinoJson/Arduino/Print.hpp index 0b0c83c0..dea9ebd6 100644 --- a/include/ArduinoJson/Arduino/Print.hpp +++ b/include/ArduinoJson/Arduino/Print.hpp @@ -12,7 +12,7 @@ // This class reproduces Arduino's Print class Print { -public: + public: virtual size_t write(uint8_t) = 0; size_t print(const char[]); diff --git a/include/ArduinoJson/Arduino/Printable.hpp b/include/ArduinoJson/Arduino/Printable.hpp index 389c5ae9..945ac224 100644 --- a/include/ArduinoJson/Arduino/Printable.hpp +++ b/include/ArduinoJson/Arduino/Printable.hpp @@ -12,7 +12,7 @@ class Print; class Printable { -public: + public: virtual size_t printTo(Print &p) const = 0; }; diff --git a/include/ArduinoJson/Internals/CompactJsonWriter.hpp b/include/ArduinoJson/Internals/CompactJsonWriter.hpp index e2df3d1b..e1252868 100644 --- a/include/ArduinoJson/Internals/CompactJsonWriter.hpp +++ b/include/ArduinoJson/Internals/CompactJsonWriter.hpp @@ -5,7 +5,7 @@ namespace ArduinoJson { namespace Internals { class CompactJsonWriter : public JsonWriter { -public: + public: explicit CompactJsonWriter(Print *sink) : JsonWriter(sink) {} virtual void beginArray() { _length += _sink->write('['); } diff --git a/include/ArduinoJson/Internals/IndentedPrint.hpp b/include/ArduinoJson/Internals/IndentedPrint.hpp index 280dcc9e..daf4d392 100644 --- a/include/ArduinoJson/Internals/IndentedPrint.hpp +++ b/include/ArduinoJson/Internals/IndentedPrint.hpp @@ -13,7 +13,7 @@ namespace Internals { // This class is used by JsonPrintable::prettyPrintTo() but can also be used // for your own purpose, like logging. class IndentedPrint : public Print { -public: + public: IndentedPrint(Print &p) : sink(&p) { level = 0; tabSize = 2; @@ -31,7 +31,7 @@ public: // Set the number of space printed for each level of indentation void setTabSize(uint8_t n); -private: + private: Print *sink; uint8_t level : 4; uint8_t tabSize : 3; @@ -39,8 +39,8 @@ private: size_t writeTabs(); - static const int MAX_LEVEL = 15; // because it's only 4 bits - static const int MAX_TAB_SIZE = 7; // because it's only 3 bits + static const int MAX_LEVEL = 15; // because it's only 4 bits + static const int MAX_TAB_SIZE = 7; // because it's only 3 bits }; } } diff --git a/include/ArduinoJson/Internals/JsonNode.hpp b/include/ArduinoJson/Internals/JsonNode.hpp index 56eb417a..f643eca5 100644 --- a/include/ArduinoJson/Internals/JsonNode.hpp +++ b/include/ArduinoJson/Internals/JsonNode.hpp @@ -44,12 +44,12 @@ class JsonNode { } asProxy; }; -public: + public: JsonNode() : next(0), type(JSON_UNDEFINED) {} JsonNode *next; - void writeTo(JsonWriter &); // TODO: <- move in JsonNodeSerializer + void writeTo(JsonWriter &); // TODO: <- move in JsonNodeSerializer void setAsArray(JsonBuffer *buffer) { type = JSON_ARRAY; @@ -104,16 +104,14 @@ public: } JsonBuffer *getContainerBuffer() { - if (type == JSON_PROXY) - return content.asProxy.target->getContainerBuffer(); + if (type == JSON_PROXY) return content.asProxy.target->getContainerBuffer(); return type == JSON_ARRAY || type == JSON_OBJECT ? content.asContainer.buffer : 0; } JsonNode *getContainerChild() { - if (type == JSON_PROXY) - return content.asProxy.target->getContainerChild(); + if (type == JSON_PROXY) return content.asProxy.target->getContainerChild(); return type == JSON_ARRAY || type == JSON_OBJECT ? content.asContainer.child : 0; } @@ -140,13 +138,14 @@ public: void duplicate(JsonNode *other); -private: + private: JsonNodeType type; JsonNodeContent content; - inline void writeArrayTo(JsonWriter &); // TODO: <- move in JsonNodeSerializer - inline void - writeObjectTo(JsonWriter &); // TODO: <- move in JsonNodeSerializer + inline void writeArrayTo( + JsonWriter &); // TODO: <- move in JsonNodeSerializer + inline void writeObjectTo( + JsonWriter &); // TODO: <- move in JsonNodeSerializer void setAsProxyOfSelf(); diff --git a/include/ArduinoJson/Internals/JsonNodeIterator.hpp b/include/ArduinoJson/Internals/JsonNodeIterator.hpp index be6a50da..49e4258c 100644 --- a/include/ArduinoJson/Internals/JsonNodeIterator.hpp +++ b/include/ArduinoJson/Internals/JsonNodeIterator.hpp @@ -6,7 +6,7 @@ namespace ArduinoJson { namespace Internals { // TODO: replace by JsonArrayIterator and JsonObjectIterator class JsonNodeIterator { -public: + public: explicit JsonNodeIterator(JsonNode *node) : _node(node) {} bool operator!=(const JsonNodeIterator &other) const { @@ -19,7 +19,7 @@ public: JsonNode *operator->() const { return _node; } -private: + private: JsonNode *_node; }; } diff --git a/include/ArduinoJson/Internals/JsonNodeWrapper.hpp b/include/ArduinoJson/Internals/JsonNodeWrapper.hpp index 27694175..d7bb60d6 100644 --- a/include/ArduinoJson/Internals/JsonNodeWrapper.hpp +++ b/include/ArduinoJson/Internals/JsonNodeWrapper.hpp @@ -9,12 +9,12 @@ namespace Internals { class JsonNodeWrapper { friend class JsonValue; -public: + public: JsonNodeWrapper() : _node(0) {} explicit JsonNodeWrapper(JsonNode *node) : _node(node) {} -protected: + protected: void duplicate(const JsonNodeWrapper &other) { if (!_node) { _node = other._node; diff --git a/include/ArduinoJson/Internals/JsonParser.hpp b/include/ArduinoJson/Internals/JsonParser.hpp index 4b046d6f..4a004de2 100644 --- a/include/ArduinoJson/Internals/JsonParser.hpp +++ b/include/ArduinoJson/Internals/JsonParser.hpp @@ -9,12 +9,12 @@ namespace Internals { class JsonNode; class JsonParser { -public: + public: JsonParser(JsonBuffer *buffer, char *json) : _buffer(buffer), _ptr(json) {} JsonNode *parseAnything(); -private: + private: JsonBuffer *_buffer; char *_ptr; diff --git a/include/ArduinoJson/Internals/JsonWriter.hpp b/include/ArduinoJson/Internals/JsonWriter.hpp index 0ea33956..95c0badb 100644 --- a/include/ArduinoJson/Internals/JsonWriter.hpp +++ b/include/ArduinoJson/Internals/JsonWriter.hpp @@ -5,7 +5,7 @@ namespace ArduinoJson { namespace Internals { class JsonWriter { -public: + public: explicit JsonWriter(Print *sink) : _sink(sink), _length(0) {} size_t bytesWritten() { return _length; } @@ -31,7 +31,7 @@ public: void writeEmptyObject() { _length += _sink->print("{}"); } -protected: + protected: Print *_sink; size_t _length; }; diff --git a/include/ArduinoJson/Internals/PrettyJsonWriter.hpp b/include/ArduinoJson/Internals/PrettyJsonWriter.hpp index 9b675746..63125c59 100644 --- a/include/ArduinoJson/Internals/PrettyJsonWriter.hpp +++ b/include/ArduinoJson/Internals/PrettyJsonWriter.hpp @@ -6,7 +6,7 @@ namespace ArduinoJson { namespace Internals { class PrettyJsonWriter : public JsonWriter { -public: + public: explicit PrettyJsonWriter(IndentedPrint *sink) : JsonWriter(sink), _indenter(sink) {} @@ -37,7 +37,7 @@ public: _length += _sink->write('}'); } -private: + private: IndentedPrint *_indenter; void indent() { diff --git a/include/ArduinoJson/Internals/QuotedString.hpp b/include/ArduinoJson/Internals/QuotedString.hpp index cc788f91..c9ed44ed 100644 --- a/include/ArduinoJson/Internals/QuotedString.hpp +++ b/include/ArduinoJson/Internals/QuotedString.hpp @@ -10,7 +10,7 @@ namespace ArduinoJson { namespace Internals { class QuotedString { -public: + public: static size_t printTo(const char *, Print *); static char *extractFrom(char *input, char **end); diff --git a/include/ArduinoJson/Internals/StringBuilder.hpp b/include/ArduinoJson/Internals/StringBuilder.hpp index 1780eedb..893530d2 100644 --- a/include/ArduinoJson/Internals/StringBuilder.hpp +++ b/include/ArduinoJson/Internals/StringBuilder.hpp @@ -10,7 +10,7 @@ namespace ArduinoJson { namespace Internals { class StringBuilder : public Print { -public: + public: StringBuilder(char *buf, int size) : buffer(buf), capacity(size - 1), length(0) { buffer[0] = 0; @@ -18,7 +18,7 @@ public: virtual size_t write(uint8_t c); -private: + private: char *buffer; int capacity; int length; diff --git a/include/ArduinoJson/JsonArray.hpp b/include/ArduinoJson/JsonArray.hpp index 52c59685..5a2bb287 100644 --- a/include/ArduinoJson/JsonArray.hpp +++ b/include/ArduinoJson/JsonArray.hpp @@ -5,7 +5,7 @@ namespace ArduinoJson { class JsonArray : public JsonContainer { -public: + public: JsonArray() {} explicit JsonArray(Internals::JsonNode *node) : JsonContainer(node) {} @@ -17,7 +17,7 @@ public: void add(double value, int decimals = 2); void add(int value) { add(static_cast(value)); } void add(long value); - void add(JsonContainer nestedArray); // TODO: should allow JsonValue too + void add(JsonContainer nestedArray); // TODO: should allow JsonValue too JsonArray createNestedArray(); JsonObject createNestedObject(); diff --git a/include/ArduinoJson/JsonArrayIterator.hpp b/include/ArduinoJson/JsonArrayIterator.hpp index f86ff755..65746bdf 100644 --- a/include/ArduinoJson/JsonArrayIterator.hpp +++ b/include/ArduinoJson/JsonArrayIterator.hpp @@ -8,7 +8,7 @@ class JsonArray; class JsonArrayIterator { friend class JsonArray; -public: + public: explicit JsonArrayIterator(Internals::JsonNode *node) : _node(node) {} void operator++() { _node = _node->next; } @@ -23,7 +23,7 @@ public: return _node != other._node; } -private: + private: Internals::JsonNode *_node; }; } \ No newline at end of file diff --git a/include/ArduinoJson/JsonBuffer.hpp b/include/ArduinoJson/JsonBuffer.hpp index 0b242a5a..3405c59a 100644 --- a/include/ArduinoJson/JsonBuffer.hpp +++ b/include/ArduinoJson/JsonBuffer.hpp @@ -13,7 +13,7 @@ class JsonBuffer { friend class Internals::JsonNode; friend class Internals::JsonParser; -public: + public: virtual ~JsonBuffer(){}; JsonArray createArray() { return JsonArray(createArrayNode()); } @@ -24,12 +24,12 @@ public: JsonArray parseArray(char *json); JsonObject parseObject(char *json); - JsonValue parseValue(char *json); // TODO: remove + JsonValue parseValue(char *json); // TODO: remove -protected: + protected: virtual void *allocateNode() = 0; -private: + private: Internals::JsonNode *createNode(); Internals::JsonNode *createArrayNode(); diff --git a/include/ArduinoJson/JsonContainer.hpp b/include/ArduinoJson/JsonContainer.hpp index 7f499d48..d128e3a1 100644 --- a/include/ArduinoJson/JsonContainer.hpp +++ b/include/ArduinoJson/JsonContainer.hpp @@ -14,7 +14,7 @@ class JsonValue; class JsonContainer : public Printable, public Internals::JsonNodeWrapper { friend class JsonArray; -public: + public: JsonContainer() {} explicit JsonContainer(Internals::JsonNode *node) : JsonNodeWrapper(node) {} @@ -30,7 +30,7 @@ public: size_t prettyPrintTo(ArduinoJson::Internals::IndentedPrint &print) const; size_t prettyPrintTo(Print &print) const; -protected: + protected: Internals::JsonNodeIterator beginChildren() const { return Internals::JsonNodeIterator(_node ? _node->getContainerChild() : 0); } diff --git a/include/ArduinoJson/JsonObject.hpp b/include/ArduinoJson/JsonObject.hpp index d17847ad..5d0c2031 100644 --- a/include/ArduinoJson/JsonObject.hpp +++ b/include/ArduinoJson/JsonObject.hpp @@ -5,7 +5,7 @@ namespace ArduinoJson { class JsonObject : public JsonContainer { -public: + public: JsonObject() {} explicit JsonObject(Internals::JsonNode *node) : JsonContainer(node) {} @@ -22,7 +22,7 @@ public: JsonObjectIterator end() { return JsonObjectIterator(0); } -private: + private: Internals::JsonNode *getOrCreateNodeAt(const char *key); }; } \ No newline at end of file diff --git a/include/ArduinoJson/JsonObjectIterator.hpp b/include/ArduinoJson/JsonObjectIterator.hpp index f40d6f4e..308e80f4 100644 --- a/include/ArduinoJson/JsonObjectIterator.hpp +++ b/include/ArduinoJson/JsonObjectIterator.hpp @@ -8,7 +8,7 @@ class JsonObject; class JsonObjectIterator { friend class JsonObject; -public: + public: explicit JsonObjectIterator(Internals::JsonNode *node) : _objectKeyValue(node) {} @@ -29,7 +29,7 @@ public: return _objectKeyValue != other._objectKeyValue; } -private: + private: JsonObjectKeyValue _objectKeyValue; }; } \ No newline at end of file diff --git a/include/ArduinoJson/JsonObjectKeyValue.hpp b/include/ArduinoJson/JsonObjectKeyValue.hpp index a2d6dd90..edc7a374 100644 --- a/include/ArduinoJson/JsonObjectKeyValue.hpp +++ b/include/ArduinoJson/JsonObjectKeyValue.hpp @@ -4,7 +4,7 @@ namespace ArduinoJson { class JsonObjectKeyValue { -public: + public: explicit JsonObjectKeyValue(Internals::JsonNode *node) : _node(node) {} const char *key() const { return _node->getAsObjectKey(); } @@ -21,7 +21,7 @@ public: Internals::JsonNode *next() { return _node->next; } -private: + private: Internals::JsonNode *_node; }; } \ No newline at end of file diff --git a/include/ArduinoJson/JsonValue.hpp b/include/ArduinoJson/JsonValue.hpp index e07fceed..128e1d31 100644 --- a/include/ArduinoJson/JsonValue.hpp +++ b/include/ArduinoJson/JsonValue.hpp @@ -8,7 +8,7 @@ class JsonContainer; class JsonObject; class JsonValue : public Internals::JsonNodeWrapper { -public: + public: JsonValue() {} explicit JsonValue(Internals::JsonNode *node) : JsonNodeWrapper(node) {} @@ -32,6 +32,9 @@ public: void set(double value, int decimals); - template T as() { return static_cast(*this); } + template + T as() { + return static_cast(*this); + } }; } \ No newline at end of file diff --git a/include/ArduinoJson/StaticJsonBuffer.hpp b/include/ArduinoJson/StaticJsonBuffer.hpp index 55cddae9..9d0200db 100644 --- a/include/ArduinoJson/StaticJsonBuffer.hpp +++ b/include/ArduinoJson/StaticJsonBuffer.hpp @@ -4,10 +4,11 @@ #include "JsonObject.hpp" namespace ArduinoJson { -template class StaticJsonBuffer : public JsonBuffer { +template +class StaticJsonBuffer : public JsonBuffer { friend class JsonObject; -public: + public: explicit StaticJsonBuffer() : _size(0) {} virtual ~StaticJsonBuffer() {} @@ -16,15 +17,14 @@ public: int size() { return _size; } -protected: + protected: virtual void *allocateNode() { - if (_size >= CAPACITY) - return 0; + if (_size >= CAPACITY) return 0; return &_buffer[_size++]; } -private: + private: Internals::JsonNode _buffer[CAPACITY]; int _size; }; diff --git a/scripts/format-code.sh b/scripts/format-code.sh index 5809e098..69bd0fdb 100644 --- a/scripts/format-code.sh +++ b/scripts/format-code.sh @@ -1 +1,2 @@ -find .. -regex ".*\.[ch]pp$" -exec clang-format -i {} \; +cd .. +find include src test -regex ".*\.[ch]pp$" -exec clang-format -style=Google -i {} \; diff --git a/src/Internals/IndentedPrint.cpp b/src/Internals/IndentedPrint.cpp index 315f6419..c9736689 100644 --- a/src/Internals/IndentedPrint.cpp +++ b/src/Internals/IndentedPrint.cpp @@ -3,25 +3,21 @@ using namespace ArduinoJson::Internals; void IndentedPrint::indent() { - if (level < MAX_LEVEL) - level++; + if (level < MAX_LEVEL) level++; } void IndentedPrint::unindent() { - if (level > 0) - level--; + if (level > 0) level--; } void IndentedPrint::setTabSize(uint8_t n) { - if (n < MAX_TAB_SIZE) - tabSize = n; + if (n < MAX_TAB_SIZE) tabSize = n; } size_t IndentedPrint::write(uint8_t c) { size_t n = 0; - if (isNewLine) - n += writeTabs(); + if (isNewLine) n += writeTabs(); n += sink->write(c); @@ -33,8 +29,7 @@ size_t IndentedPrint::write(uint8_t c) { inline size_t IndentedPrint::writeTabs() { size_t n = 0; - for (int i = 0; i < level * tabSize; i++) - n += sink->write(' '); + for (int i = 0; i < level * tabSize; i++) n += sink->write(' '); return n; } \ No newline at end of file diff --git a/src/Internals/JsonNode.cpp b/src/Internals/JsonNode.cpp index aafc9ba8..9d3c0a0b 100644 --- a/src/Internals/JsonNode.cpp +++ b/src/Internals/JsonNode.cpp @@ -9,42 +9,40 @@ using namespace ArduinoJson::Internals; void JsonNode::writeTo(JsonWriter &writer) { switch (type) { - case JSON_PROXY: - content.asProxy.target->writeTo(writer); - break; + case JSON_PROXY: + content.asProxy.target->writeTo(writer); + break; - case JSON_ARRAY: - writeArrayTo(writer); - break; + case JSON_ARRAY: + writeArrayTo(writer); + break; - case JSON_OBJECT: - writeObjectTo(writer); - break; + case JSON_OBJECT: + writeObjectTo(writer); + break; - case JSON_STRING: - writer.writeString(content.asString); - break; + case JSON_STRING: + writer.writeString(content.asString); + break; - case JSON_LONG: - writer.writeInteger(content.asInteger); - break; + case JSON_LONG: + writer.writeInteger(content.asInteger); + break; - case JSON_BOOLEAN: - writer.writeBoolean(content.asBoolean); - break; + case JSON_BOOLEAN: + writer.writeBoolean(content.asBoolean); + break; - default: // >= JSON_DOUBLE_0_DECIMALS - writer.writeDouble(content.asDouble, type - JSON_DOUBLE_0_DECIMALS); - break; + default: // >= JSON_DOUBLE_0_DECIMALS + writer.writeDouble(content.asDouble, type - JSON_DOUBLE_0_DECIMALS); + break; } } void JsonNode::addChild(JsonNode *childToAdd) { - if (type == JSON_PROXY) - return content.asProxy.target->addChild(childToAdd); + if (type == JSON_PROXY) return content.asProxy.target->addChild(childToAdd); - if (type != JSON_ARRAY && type != JSON_OBJECT) - return; + if (type != JSON_ARRAY && type != JSON_OBJECT) return; JsonNode *lastChild = content.asContainer.child; @@ -53,8 +51,7 @@ void JsonNode::addChild(JsonNode *childToAdd) { return; } - while (lastChild->next) - lastChild = lastChild->next; + while (lastChild->next) lastChild = lastChild->next; lastChild->next = childToAdd; } @@ -63,8 +60,7 @@ void JsonNode::removeChild(JsonNode *childToRemove) { if (type == JSON_PROXY) return content.asProxy.target->removeChild(childToRemove); - if (type != JSON_ARRAY && type != JSON_OBJECT) - return; + if (type != JSON_ARRAY && type != JSON_OBJECT) return; if (content.asContainer.child == childToRemove) { content.asContainer.child = childToRemove->next; @@ -73,8 +69,7 @@ void JsonNode::removeChild(JsonNode *childToRemove) { for (JsonNode *child = content.asContainer.child; child; child = child->next) { - if (child->next == childToRemove) - child->next = childToRemove->next; + if (child->next == childToRemove) child->next = childToRemove->next; } } @@ -88,8 +83,7 @@ void JsonNode::writeArrayTo(JsonWriter &writer) { child->writeTo(writer); child = child->next; - if (!child) - break; + if (!child) break; writer.writeComma(); } @@ -112,8 +106,7 @@ void JsonNode::writeObjectTo(JsonWriter &writer) { child->content.asKeyValue.value->writeTo(writer); child = child->next; - if (!child) - break; + if (!child) break; writer.writeComma(); } @@ -126,12 +119,10 @@ void JsonNode::writeObjectTo(JsonWriter &writer) { void JsonNode::setAsProxyOfSelf() { JsonBuffer *buffer = content.asContainer.buffer; - if (!buffer) - return; + if (!buffer) return; JsonNode *newNode = buffer->createNode(); - if (!newNode) - return; + if (!newNode) return; *newNode = *this; diff --git a/src/Internals/JsonParser.cpp b/src/Internals/JsonParser.cpp index a05f1d09..713eb466 100644 --- a/src/Internals/JsonParser.cpp +++ b/src/Internals/JsonParser.cpp @@ -1,6 +1,6 @@ #include "ArduinoJson/Internals/JsonParser.hpp" -#include // for strtol, strtod +#include // for strtol, strtod #include #include "ArduinoJson/JsonBuffer.hpp" @@ -9,14 +9,12 @@ using namespace ArduinoJson::Internals; void JsonParser::skipSpaces() { - while (isspace(*_ptr)) - _ptr++; + while (isspace(*_ptr)) _ptr++; } bool JsonParser::skip(char charToSkip) { skipSpaces(); - if (*_ptr != charToSkip) - return false; + if (*_ptr != charToSkip) return false; _ptr++; skipSpaces(); return true; @@ -26,39 +24,39 @@ JsonNode *JsonParser::parseAnything() { skipSpaces(); switch (*_ptr) { - case '[': - return parseArray(); + case '[': + return parseArray(); - case 't': - case 'f': - return parseBoolean(); + case 't': + case 'f': + return parseBoolean(); - case '-': - case '.': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - return parseNumber(); + case '-': + case '.': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + return parseNumber(); - case 'n': - return parseNull(); + case 'n': + return parseNull(); - case '{': - return parseObject(); + case '{': + return parseObject(); - case '\'': - case '\"': - return parseString(); + case '\'': + case '\"': + return parseString(); - default: - return NULL; // invalid JSON + default: + return NULL; // invalid JSON } } @@ -67,25 +65,20 @@ JsonNode *JsonParser::parseArray() { skip('['); - if (isEnd()) - return 0; + if (isEnd()) return 0; - if (skip(']')) - return node; // empty array + if (skip(']')) return node; // empty array for (;;) { JsonNode *child = parseAnything(); - if (!child) - return 0; // child parsing failed + if (!child) return 0; // child parsing failed node->addChild(child); - if (skip(']')) - return node; // end of the array + if (skip(']')) return node; // end of the array - if (!skip(',')) - return 0; // comma is missing + if (!skip(',')) return 0; // comma is missing } } @@ -103,7 +96,7 @@ 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; @@ -115,7 +108,7 @@ JsonNode *JsonParser::parseNumber() { } JsonNode *JsonParser::parseNull() { - _ptr += 4; // strlen("null") + _ptr += 4; // strlen("null") return _buffer->createStringNode(0); } @@ -125,41 +118,33 @@ JsonNode *JsonParser::parseObject() { skip('{'); - if (isEnd()) - return 0; // premature ending + if (isEnd()) return 0; // premature ending - if (skip('}')) - return node; // empty object + if (skip('}')) return node; // empty object for (;;) { JsonNode *child = parseObjectKeyValue(); - if (!child) - return 0; // child parsing failed + if (!child) return 0; // child parsing failed node->addChild(child); - if (skip('}')) - return node; // end of the object + if (skip('}')) return node; // end of the object - if (!skip(',')) - return 0; // comma is missing + if (!skip(',')) return 0; // comma is missing } } JsonNode *JsonParser::parseObjectKeyValue() { const char *key = QuotedString::extractFrom(_ptr, &_ptr); - if (!key) - return 0; // failed to extract key + if (!key) return 0; // failed to extract key - if (!skip(':')) - return 0; // colon is missing + if (!skip(':')) return 0; // colon is missing JsonNode *value = parseAnything(); - if (!value) - return 0; // value parsing failed + if (!value) return 0; // value parsing failed return _buffer->createObjectKeyValueNode(key, value); } diff --git a/src/Internals/QuotedString.cpp b/src/Internals/QuotedString.cpp index 4a57dbe1..9231f6fa 100644 --- a/src/Internals/QuotedString.cpp +++ b/src/Internals/QuotedString.cpp @@ -27,8 +27,7 @@ static inline size_t printCharTo(char c, Print *p) { } size_t QuotedString::printTo(const char *s, Print *p) { - if (!s) - return p->print("null"); + if (!s) return p->print("null"); size_t n = p->write('\"'); @@ -45,10 +44,8 @@ static char unescapeChar(char c) { const char *p = "b\bf\fn\nr\rt\t"; for (;;) { - if (p[0] == 0) - return c; - if (p[0] == c) - return p[1]; + if (p[0] == 0) return c; + if (p[0] == c) return p[1]; p += 2; } } @@ -63,9 +60,9 @@ char *QuotedString::extractFrom(char *input, char **endPtr) { return 0; } - char stopChar = firstChar; // closing quote is the same as opening quote + char stopChar = firstChar; // closing quote is the same as opening quote - char *startPtr = input + 1; // skip the quote + char *startPtr = input + 1; // skip the quote char *readPtr = startPtr; char *writePtr = startPtr; char c; diff --git a/src/Internals/StringBuilder.cpp b/src/Internals/StringBuilder.cpp index 962067ee..d201c013 100644 --- a/src/Internals/StringBuilder.cpp +++ b/src/Internals/StringBuilder.cpp @@ -8,8 +8,7 @@ using namespace ArduinoJson::Internals; size_t StringBuilder::write(uint8_t c) { - if (length >= capacity) - return 0; + if (length >= capacity) return 0; buffer[length++] = c; buffer[length] = 0; diff --git a/src/JsonArray.cpp b/src/JsonArray.cpp index cacc86cb..549ea6f6 100644 --- a/src/JsonArray.cpp +++ b/src/JsonArray.cpp @@ -7,8 +7,7 @@ using namespace ArduinoJson::Internals; JsonValue JsonArray::operator[](int index) const { for (JsonNodeIterator it = beginChildren(); it != endChildren(); ++it) { - if (!index) - return JsonValue(*it); + if (!index) return JsonValue(*it); index--; } @@ -17,8 +16,7 @@ JsonValue JsonArray::operator[](int index) const { void JsonArray::add(bool value) { JsonNode *node = createNode(); - if (!node) - return; + if (!node) return; node->setAsBoolean(value); addChild(node); @@ -26,8 +24,7 @@ void JsonArray::add(bool value) { void JsonArray::add(char const *value) { JsonNode *node = createNode(); - if (!node) - return; + if (!node) return; node->setAsString(value); addChild(node); @@ -35,8 +32,7 @@ void JsonArray::add(char const *value) { void JsonArray::add(double value, int decimals) { JsonNode *node = createNode(); - if (!node) - return; + if (!node) return; node->setAsDouble(value, decimals); addChild(node); @@ -44,8 +40,7 @@ void JsonArray::add(double value, int decimals) { void JsonArray::add(long value) { JsonNode *node = createNode(); - if (!node) - return; + if (!node) return; node->setAsLong(value); addChild(node); @@ -54,8 +49,7 @@ void JsonArray::add(long value) { // TODO: we should have the same issue as in JsonValue void JsonArray::add(JsonContainer nestedContainer) { JsonNode *node = createNode(); - if (!node) - return; + if (!node) return; node->duplicate(nestedContainer._node); addChild(node); @@ -84,8 +78,7 @@ JsonObject JsonArray::createNestedObject() { } JsonArrayIterator JsonArray::begin() { - if (!_node) - return end(); + if (!_node) return end(); return JsonArrayIterator(_node->getContainerChild()); } \ No newline at end of file diff --git a/src/JsonBuffer.cpp b/src/JsonBuffer.cpp index 3e3d0f6e..587a57fc 100644 --- a/src/JsonBuffer.cpp +++ b/src/JsonBuffer.cpp @@ -13,8 +13,7 @@ JsonValue JsonBuffer::createValue() { return JsonValue(createNode()); } JsonNode *JsonBuffer::createNode() { void *node = allocateNode(); - if (!node) - return 0; + if (!node) return 0; return new (node) JsonNode(); } @@ -37,8 +36,7 @@ JsonValue JsonBuffer::parseValue(char *json) { JsonNode *JsonBuffer::createArrayNode() { JsonNode *node = createNode(); - if (node) - node->setAsArray(this); + if (node) node->setAsArray(this); return node; } @@ -46,8 +44,7 @@ JsonNode *JsonBuffer::createArrayNode() { JsonNode *JsonBuffer::createBoolNode(bool value) { JsonNode *node = createNode(); - if (node) - node->setAsBoolean(value); + if (node) node->setAsBoolean(value); return node; } @@ -55,8 +52,7 @@ JsonNode *JsonBuffer::createBoolNode(bool value) { JsonNode *JsonBuffer::createDoubleNode(double value, int decimals) { JsonNode *node = createNode(); - if (node) - node->setAsDouble(value, decimals); + if (node) node->setAsDouble(value, decimals); return node; } @@ -64,8 +60,7 @@ JsonNode *JsonBuffer::createDoubleNode(double value, int decimals) { JsonNode *JsonBuffer::createLongNode(long value) { JsonNode *node = createNode(); - if (node) - node->setAsLong(value); + if (node) node->setAsLong(value); return node; } @@ -73,8 +68,7 @@ JsonNode *JsonBuffer::createLongNode(long value) { JsonNode *JsonBuffer::createObjectNode() { JsonNode *node = createNode(); - if (node) - node->setAsObject(this); + if (node) node->setAsObject(this); return node; } @@ -83,8 +77,7 @@ Internals::JsonNode *JsonBuffer::createObjectKeyValueNode(const char *key, JsonNode *value) { JsonNode *node = createNode(); - if (node) - node->setAsObjectKeyValue(key, value); + if (node) node->setAsObjectKeyValue(key, value); return node; } @@ -92,8 +85,7 @@ Internals::JsonNode *JsonBuffer::createObjectKeyValueNode(const char *key, JsonNode *JsonBuffer::createStringNode(const char *value) { JsonNode *node = createNode(); - if (node) - node->setAsString(value); + if (node) node->setAsString(value); return node; } \ No newline at end of file diff --git a/src/JsonContainer.cpp b/src/JsonContainer.cpp index ed03d404..db87b85c 100644 --- a/src/JsonContainer.cpp +++ b/src/JsonContainer.cpp @@ -36,32 +36,26 @@ size_t JsonContainer::prettyPrintTo(Print &print) const { } JsonNode *JsonContainer::createNode() { - if (!_node) - return 0; + if (!_node) return 0; JsonBuffer *buffer = _node->getContainerBuffer(); - if (!buffer) - return 0; + if (!buffer) return 0; return buffer->createNode(); } bool JsonContainer::operator==(const JsonContainer &other) const { - if (_node == other._node) - return true; - if (!_node || !other._node) - return false; + if (_node == other._node) return true; + if (!_node || !other._node) return false; return _node->getProxyTarget() == other._node->getProxyTarget(); } void JsonContainer::addChild(JsonNode *childToAdd) { - if (_node) - _node->addChild(childToAdd); + if (_node) _node->addChild(childToAdd); } void JsonContainer::removeChild(JsonNode *childToRemove) { - if (_node) - _node->removeChild(childToRemove); + if (_node) _node->removeChild(childToRemove); } size_t JsonContainer::size() const { diff --git a/src/JsonObject.cpp b/src/JsonObject.cpp index f583d4f9..7eeacbcb 100644 --- a/src/JsonObject.cpp +++ b/src/JsonObject.cpp @@ -1,6 +1,6 @@ #include "ArduinoJson/JsonObject.hpp" -#include // for strcmp +#include // for strcmp #include "ArduinoJson/JsonBuffer.hpp" #include "ArduinoJson/JsonValue.hpp" @@ -28,8 +28,7 @@ void JsonObject::remove(char const *key) { JsonArray JsonObject::createNestedArray(char const *key) { JsonNode *node = getOrCreateNodeAt(key); - if (node) - node->setAsArray(_node->getContainerBuffer()); + if (node) node->setAsArray(_node->getContainerBuffer()); return JsonArray(node); } @@ -37,8 +36,7 @@ JsonArray JsonObject::createNestedArray(char const *key) { JsonObject JsonObject::createNestedObject(char const *key) { JsonNode *node = getOrCreateNodeAt(key); - if (node) - node->setAsObject(_node->getContainerBuffer()); + if (node) node->setAsObject(_node->getContainerBuffer()); return JsonObject(node); } @@ -47,17 +45,14 @@ JsonNode *JsonObject::getOrCreateNodeAt(const char *key) { for (JsonNodeIterator it = beginChildren(); it != endChildren(); ++it) { const char *childKey = it->getAsObjectKey(); - if (!strcmp(childKey, key)) - return it->getAsObjectValue(); + if (!strcmp(childKey, key)) return it->getAsObjectValue(); } JsonNode *newValueNode = createNode(); - if (!newValueNode) - return 0; + if (!newValueNode) return 0; JsonNode *newKeyNode = createNode(); - if (!newKeyNode) - return 0; + if (!newKeyNode) return 0; newKeyNode->setAsObjectKeyValue(key, newValueNode); diff --git a/src/JsonValue.cpp b/src/JsonValue.cpp index cd531520..14e999bf 100644 --- a/src/JsonValue.cpp +++ b/src/JsonValue.cpp @@ -7,23 +7,19 @@ using namespace ArduinoJson; void JsonValue::operator=(bool value) { - if (_node) - _node->setAsBoolean(value); + if (_node) _node->setAsBoolean(value); } void JsonValue::operator=(char const *value) { - if (_node) - _node->setAsString(value); + if (_node) _node->setAsString(value); } void JsonValue::set(double value, int decimals) { - if (_node) - _node->setAsDouble(value, decimals); + if (_node) _node->setAsDouble(value, decimals); } void JsonValue::operator=(int value) { - if (_node) - _node->setAsLong(value); + if (_node) _node->setAsLong(value); } JsonValue::operator bool() const { diff --git a/test/Issue10.cpp b/test/Issue10.cpp index f56e9877..4af8647d 100644 --- a/test/Issue10.cpp +++ b/test/Issue10.cpp @@ -12,7 +12,7 @@ struct Person { }; class Issue10 : public testing::Test { -protected: + protected: virtual void SetUp() { Person boss; boss.id = 1; @@ -47,8 +47,8 @@ TEST_F(Issue10, PopulateArrayByAddingAnObject) { object["id"] = persons[i].id; object["name"] = persons[i].name; - array.add(object); // <- adds a reference to an existing objet (creates 2 - // extra proxy nodes) + array.add(object); // <- adds a reference to an existing objet (creates 2 + // extra proxy nodes) } checkJsonString(array); diff --git a/test/JsonArray_Container_Tests.cpp b/test/JsonArray_Container_Tests.cpp index 54203bd0..28c37926 100644 --- a/test/JsonArray_Container_Tests.cpp +++ b/test/JsonArray_Container_Tests.cpp @@ -5,16 +5,18 @@ using namespace ArduinoJson; class JsonArray_Container_Tests : public ::testing::Test { -protected: + protected: virtual void SetUp() { array = json.createArray(); } void nodeCountMustBe(int expected) { EXPECT_EQ(expected, json.size()); } - template void firstElementMustBe(T expected) { + template + void firstElementMustBe(T expected) { elementAtIndexMustBe(0, expected); } - template void secondElementMustBe(T expected) { + template + void secondElementMustBe(T expected) { elementAtIndexMustBe(1, expected); } @@ -23,8 +25,9 @@ protected: StaticJsonBuffer<42> json; JsonArray array; -private: - template void elementAtIndexMustBe(int index, T expected) { + private: + template + void elementAtIndexMustBe(int index, T expected) { EXPECT_EQ(expected, array[index].as()); } }; diff --git a/test/JsonArray_Iterator_Tests.cpp b/test/JsonArray_Iterator_Tests.cpp index 2e91edd0..f479a75c 100644 --- a/test/JsonArray_Iterator_Tests.cpp +++ b/test/JsonArray_Iterator_Tests.cpp @@ -15,10 +15,10 @@ TEST(JsonArray_Iterator_Test, SimpleTest) { JsonArrayIterator end = array.end(); EXPECT_NE(end, it); - EXPECT_EQ(12, (*it).as()); // TODO: use -> + EXPECT_EQ(12, (*it).as()); // TODO: use -> ++it; EXPECT_NE(end, it); - EXPECT_EQ(34, (*it).as()); // TODO: use -> + EXPECT_EQ(34, (*it).as()); // TODO: use -> ++it; EXPECT_EQ(array.end(), it); } \ No newline at end of file diff --git a/test/JsonArray_PrettyPrintTo_Tests.cpp b/test/JsonArray_PrettyPrintTo_Tests.cpp index 437ac7c6..7c8639da 100644 --- a/test/JsonArray_PrettyPrintTo_Tests.cpp +++ b/test/JsonArray_PrettyPrintTo_Tests.cpp @@ -12,7 +12,7 @@ using namespace ArduinoJson; class JsonArray_PrettyPrintTo_Tests : public testing::Test { -protected: + protected: JsonArray array; StaticJsonBuffer<30> json; @@ -24,7 +24,7 @@ protected: EXPECT_EQ(strlen(expected), n); } -private: + private: char buffer[256]; }; @@ -33,29 +33,32 @@ TEST_F(JsonArray_PrettyPrintTo_Tests, Empty) { outputMustBe("[]"); } TEST_F(JsonArray_PrettyPrintTo_Tests, OneElement) { array.add(1); - outputMustBe("[\r\n" - " 1\r\n" - "]"); + outputMustBe( + "[\r\n" + " 1\r\n" + "]"); } TEST_F(JsonArray_PrettyPrintTo_Tests, TwoElements) { array.add(1); array.add(2); - outputMustBe("[\r\n" - " 1,\r\n" - " 2\r\n" - "]"); + outputMustBe( + "[\r\n" + " 1,\r\n" + " 2\r\n" + "]"); } TEST_F(JsonArray_PrettyPrintTo_Tests, EmptyNestedArrays) { array.createNestedArray(); array.createNestedArray(); - outputMustBe("[\r\n" - " [],\r\n" - " []\r\n" - "]"); + outputMustBe( + "[\r\n" + " [],\r\n" + " []\r\n" + "]"); } TEST_F(JsonArray_PrettyPrintTo_Tests, NestedArrays) { @@ -66,13 +69,14 @@ TEST_F(JsonArray_PrettyPrintTo_Tests, NestedArrays) { 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" + "]"); } \ No newline at end of file diff --git a/test/JsonArray_PrintTo_Tests.cpp b/test/JsonArray_PrintTo_Tests.cpp index 71fa6c29..e8233fbf 100644 --- a/test/JsonArray_PrintTo_Tests.cpp +++ b/test/JsonArray_PrintTo_Tests.cpp @@ -11,7 +11,7 @@ using namespace ArduinoJson; class JsonArray_PrintTo_Tests : public testing::Test { -protected: + protected: JsonArray array; StaticJsonBuffer<3> json; @@ -23,7 +23,7 @@ protected: EXPECT_EQ(strlen(expected), n); } -private: + private: char buffer[256]; }; diff --git a/test/JsonObject_Container_Tests.cpp b/test/JsonObject_Container_Tests.cpp index f63b8af0..a8fd3f56 100644 --- a/test/JsonObject_Container_Tests.cpp +++ b/test/JsonObject_Container_Tests.cpp @@ -5,7 +5,7 @@ using namespace ArduinoJson; class JsonObject_Container_Tests : public ::testing::Test { -protected: + protected: virtual void SetUp() { object = json.createObject(); } StaticJsonBuffer<42> json; diff --git a/test/JsonObject_PrettyPrintTo_Tests.cpp b/test/JsonObject_PrettyPrintTo_Tests.cpp index feb07eae..032eb04a 100644 --- a/test/JsonObject_PrettyPrintTo_Tests.cpp +++ b/test/JsonObject_PrettyPrintTo_Tests.cpp @@ -11,7 +11,7 @@ using namespace ArduinoJson; class JsonObject_PrettyPrintTo_Tests : public testing::Test { -protected: + protected: JsonObject object; StaticJsonBuffer<30> json; @@ -23,7 +23,7 @@ protected: EXPECT_EQ(strlen(expected), n); } -private: + private: char buffer[256]; }; @@ -32,29 +32,32 @@ TEST_F(JsonObject_PrettyPrintTo_Tests, EmptyObject) { outputMustBe("{}"); } TEST_F(JsonObject_PrettyPrintTo_Tests, OneMember) { object["key"] = "value"; - outputMustBe("{\r\n" - " \"key\": \"value\"\r\n" - "}"); + outputMustBe( + "{\r\n" + " \"key\": \"value\"\r\n" + "}"); } TEST_F(JsonObject_PrettyPrintTo_Tests, TwoMembers) { object["key1"] = "value1"; object["key2"] = "value2"; - outputMustBe("{\r\n" - " \"key1\": \"value1\",\r\n" - " \"key2\": \"value2\"\r\n" - "}"); + outputMustBe( + "{\r\n" + " \"key1\": \"value1\",\r\n" + " \"key2\": \"value2\"\r\n" + "}"); } TEST_F(JsonObject_PrettyPrintTo_Tests, EmptyNestedContainers) { object.createNestedObject("key1"); object.createNestedArray("key2"); - outputMustBe("{\r\n" - " \"key1\": {},\r\n" - " \"key2\": []\r\n" - "}"); + outputMustBe( + "{\r\n" + " \"key1\": {},\r\n" + " \"key2\": []\r\n" + "}"); } TEST_F(JsonObject_PrettyPrintTo_Tests, NestedContainers) { @@ -64,12 +67,13 @@ TEST_F(JsonObject_PrettyPrintTo_Tests, NestedContainers) { JsonArray nested2 = object.createNestedArray("key2"); nested2.add(2); - outputMustBe("{\r\n" - " \"key1\": {\r\n" - " \"a\": 1\r\n" - " },\r\n" - " \"key2\": [\r\n" - " 2\r\n" - " ]\r\n" - "}"); + outputMustBe( + "{\r\n" + " \"key1\": {\r\n" + " \"a\": 1\r\n" + " },\r\n" + " \"key2\": [\r\n" + " 2\r\n" + " ]\r\n" + "}"); } \ No newline at end of file diff --git a/test/JsonObject_Serialization_Tests.cpp b/test/JsonObject_Serialization_Tests.cpp index 17351769..8035678b 100644 --- a/test/JsonObject_Serialization_Tests.cpp +++ b/test/JsonObject_Serialization_Tests.cpp @@ -7,7 +7,7 @@ using namespace ArduinoJson; class JsonObject_Serialization_Tests : public testing::Test { -protected: + protected: virtual void SetUp() { object = json.createObject(); } void outputMustBe(const char *expected) { diff --git a/test/JsonParser_Array_Tests.cpp b/test/JsonParser_Array_Tests.cpp index e9d282a0..1c126766 100644 --- a/test/JsonParser_Array_Tests.cpp +++ b/test/JsonParser_Array_Tests.cpp @@ -5,7 +5,7 @@ using namespace ArduinoJson; class JsonParser_Array_Tests : public testing::Test { -protected: + protected: void whenInputIs(const char *json) { strcpy(_jsonString, json); _array = _jsonBuffer.parseArray(_jsonString); @@ -20,15 +20,18 @@ protected: void sizeMustBe(int expected) { EXPECT_EQ(expected, _array.size()); } - template void firstElementMustBe(T expected) { + template + void firstElementMustBe(T expected) { elementAtIndexMustBe(0, expected); } - template void secondElementMustBe(T expected) { + template + void secondElementMustBe(T expected) { elementAtIndexMustBe(1, expected); } - template void elementAtIndexMustBe(int index, T expected) { + template + void elementAtIndexMustBe(int index, T expected) { EXPECT_EQ(expected, _array[index].as()); } diff --git a/test/JsonParser_Object_Tests.cpp b/test/JsonParser_Object_Tests.cpp index 1750e6a3..20124be6 100644 --- a/test/JsonParser_Object_Tests.cpp +++ b/test/JsonParser_Object_Tests.cpp @@ -5,7 +5,7 @@ using namespace ArduinoJson; class JsonParser_Object_Test : public testing::Test { -protected: + protected: void whenInputIs(const char *jsonString) { strcpy(_jsonString, jsonString); _object = _jsonBuffer.parseObject(_jsonString); @@ -21,11 +21,12 @@ protected: EXPECT_STREQ(expected, _object[key].as()); } - template void keyMustHaveValue(const char *key, T expected) { + template + void keyMustHaveValue(const char *key, T expected) { EXPECT_EQ(expected, _object[key].as()); } -private: + private: StaticJsonBuffer<10> _jsonBuffer; JsonObject _object; char _jsonString[256]; diff --git a/test/JsonValueTests.cpp b/test/JsonValueTests.cpp index 58511f5e..5d23723b 100644 --- a/test/JsonValueTests.cpp +++ b/test/JsonValueTests.cpp @@ -5,7 +5,7 @@ using namespace ArduinoJson; class JsonValueTests : public ::testing::Test { -protected: + protected: virtual void SetUp() { jsonValue1 = json.createValue(); jsonValue2 = json.createValue(); diff --git a/test/QuotedString_ExtractFrom_Tests.cpp b/test/QuotedString_ExtractFrom_Tests.cpp index c05d002a..03f149cb 100644 --- a/test/QuotedString_ExtractFrom_Tests.cpp +++ b/test/QuotedString_ExtractFrom_Tests.cpp @@ -4,7 +4,7 @@ using namespace ArduinoJson::Internals; class QuotedString_ExtractFrom_Tests : public testing::Test { -protected: + protected: void whenInputIs(const char *json) { strcpy(_jsonString, json); _result = QuotedString::extractFrom(_jsonString, &_trailing); @@ -16,7 +16,7 @@ protected: EXPECT_STREQ(expected, _trailing); } -private: + private: char _jsonString[256]; char *_result; char *_trailing; diff --git a/test/QuotedString_PrintTo_Tests.cpp b/test/QuotedString_PrintTo_Tests.cpp index 1638f681..4db3a5a1 100644 --- a/test/QuotedString_PrintTo_Tests.cpp +++ b/test/QuotedString_PrintTo_Tests.cpp @@ -6,7 +6,7 @@ using namespace ArduinoJson::Internals; class QuotedString_PrintTo_Tests : public testing::Test { -protected: + protected: void whenInputIs(const char *input) { StringBuilder sb(buffer, sizeof(buffer)); returnValue = QuotedString::printTo(input, &sb); @@ -17,7 +17,7 @@ protected: EXPECT_EQ(strlen(expected), returnValue); } -private: + private: char buffer[1024]; size_t returnValue; }; @@ -44,7 +44,7 @@ TEST_F(QuotedString_PrintTo_Tests, ReverseSolidus) { TEST_F(QuotedString_PrintTo_Tests, Solidus) { whenInputIs("/"); - outputMustBe("\"/\""); // but the JSON format allows \/ + outputMustBe("\"/\""); // but the JSON format allows \/ } TEST_F(QuotedString_PrintTo_Tests, Backspace) { diff --git a/test/StringBuilderTests.cpp b/test/StringBuilderTests.cpp index 8666d749..f2f08728 100644 --- a/test/StringBuilderTests.cpp +++ b/test/StringBuilderTests.cpp @@ -4,7 +4,7 @@ using namespace ArduinoJson::Internals; class StringBuilderTests : public testing::Test { -protected: + protected: virtual void SetUp() { sb = new StringBuilder(buffer, sizeof(buffer)); } void print(const char *value) { returnValue = sb->print(value); } @@ -13,7 +13,7 @@ protected: void resultMustBe(size_t expected) { EXPECT_EQ(expected, returnValue); } -private: + private: char buffer[20]; Print *sb; size_t returnValue;