diff --git a/JsonGenerator/JsonValue.h b/JsonGenerator/JsonValue.h index 56318e75..3f4db084 100644 --- a/JsonGenerator/JsonValue.h +++ b/JsonGenerator/JsonValue.h @@ -59,6 +59,11 @@ namespace ArduinoJson content.asDouble = value; } + operator const char*() + { + return ""; + } + size_t printTo(Print& p) const { // handmade polymorphism diff --git a/JsonGeneratorTests/JsonGeneratorTests.vcxproj b/JsonGeneratorTests/JsonGeneratorTests.vcxproj index 13ae0299..c93033ea 100644 --- a/JsonGeneratorTests/JsonGeneratorTests.vcxproj +++ b/JsonGeneratorTests/JsonGeneratorTests.vcxproj @@ -86,6 +86,7 @@ + diff --git a/JsonGeneratorTests/JsonGeneratorTests.vcxproj.filters b/JsonGeneratorTests/JsonGeneratorTests.vcxproj.filters index ef75b1f8..a60339b6 100644 --- a/JsonGeneratorTests/JsonGeneratorTests.vcxproj.filters +++ b/JsonGeneratorTests/JsonGeneratorTests.vcxproj.filters @@ -30,5 +30,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/JsonGeneratorTests/JsonObject_Indexer_Tests.cpp b/JsonGeneratorTests/JsonObject_Indexer_Tests.cpp new file mode 100644 index 00000000..73fa9dde --- /dev/null +++ b/JsonGeneratorTests/JsonObject_Indexer_Tests.cpp @@ -0,0 +1,42 @@ +/* +* Arduino JSON library +* Benoit Blanchon 2014 - MIT License +*/ + +#include "CppUnitTest.h" +#include "JsonArray.h" +#include "JsonObject.h" + +using namespace Microsoft::VisualStudio::CppUnitTestFramework; +using namespace ArduinoJson::Generator; + +namespace JsonGeneratorTests +{ + TEST_CLASS(JsonObject_Indexer_Tests) + { + JsonObject<2> object; + + public: + + /* TEST_METHOD(Empty) + { + mustNotContain("key"); + }*/ + + TEST_METHOD(OneString) + { + object["key"] = "value"; + + mustContain("key", "value"); + } + + + private: + + void mustContain(const char* key, const char* expected) + { + auto actual = (const char*) object[key]; + Assert::AreEqual(expected, actual); + } + }; +} \ No newline at end of file