diff --git a/JsonGenerator/IndentedPrintDecorator.cpp b/JsonGenerator/IndentedPrintDecorator.cpp index 51add965..b790036e 100644 --- a/JsonGenerator/IndentedPrintDecorator.cpp +++ b/JsonGenerator/IndentedPrintDecorator.cpp @@ -7,5 +7,5 @@ size_t IndentedPrintDecorator::write(uint8_t c) { - return print.write(c); + return sink.write(c); } \ No newline at end of file diff --git a/JsonGenerator/IndentedPrintDecorator.h b/JsonGenerator/IndentedPrintDecorator.h index 631ea255..6800e00f 100644 --- a/JsonGenerator/IndentedPrintDecorator.h +++ b/JsonGenerator/IndentedPrintDecorator.h @@ -13,7 +13,7 @@ class IndentedPrintDecorator : public Print public: IndentedPrintDecorator(Print& p) - : currentLevel(0), print(p) + : currentLevel(0), sink(p) { } @@ -21,6 +21,6 @@ public: private: int currentLevel; - Print& print; + Print& sink; }; diff --git a/JsonGeneratorTests/IntentedPrintTests.cpp b/JsonGeneratorTests/IntentedPrintTests.cpp new file mode 100644 index 00000000..62e8b853 --- /dev/null +++ b/JsonGeneratorTests/IntentedPrintTests.cpp @@ -0,0 +1,42 @@ +/* +* Arduino JSON library +* Benoit Blanchon 2014 - MIT License +*/ + +#include "CppUnitTest.h" +#include "IndentedPrintDecorator.h" +#include "StringBuilder.h" + +using namespace ArduinoJson::Internals; +using namespace Microsoft::VisualStudio::CppUnitTestFramework; + +namespace JsonGeneratorTests +{ + TEST_CLASS(IntentedPrintTests) + { + char buffer[256]; + + public: + + TEST_METHOD(EmptyString) + { + whenInputIs(""); + outputMustBe(""); + } + + private: + + void whenInputIs(const char input[]) + { + StringBuilder sb(buffer, sizeof(buffer)); + IndentedPrintDecorator decorator(sb); + + decorator.print(input); + } + + void outputMustBe(const char* expected) + { + Assert::AreEqual(expected, buffer); + } + }; +} \ No newline at end of file diff --git a/JsonGeneratorTests/JsonGeneratorTests.vcxproj b/JsonGeneratorTests/JsonGeneratorTests.vcxproj index d9ee8ff8..22132844 100644 --- a/JsonGeneratorTests/JsonGeneratorTests.vcxproj +++ b/JsonGeneratorTests/JsonGeneratorTests.vcxproj @@ -85,6 +85,7 @@ + diff --git a/JsonGeneratorTests/JsonGeneratorTests.vcxproj.filters b/JsonGeneratorTests/JsonGeneratorTests.vcxproj.filters index a0439471..47af2728 100644 --- a/JsonGeneratorTests/JsonGeneratorTests.vcxproj.filters +++ b/JsonGeneratorTests/JsonGeneratorTests.vcxproj.filters @@ -39,5 +39,8 @@ Source Files + + Source Files + \ No newline at end of file