forked from bblanchon/ArduinoJson
Added a failng test
This commit is contained in:
@ -59,6 +59,11 @@ namespace ArduinoJson
|
|||||||
content.asDouble = value;
|
content.asDouble = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
operator const char*()
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
size_t printTo(Print& p) const
|
size_t printTo(Print& p) const
|
||||||
{
|
{
|
||||||
// handmade polymorphism
|
// handmade polymorphism
|
||||||
|
@ -86,6 +86,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="EscapedStringTests.cpp" />
|
<ClCompile Include="EscapedStringTests.cpp" />
|
||||||
<ClCompile Include="JsonArrayTests.cpp" />
|
<ClCompile Include="JsonArrayTests.cpp" />
|
||||||
|
<ClCompile Include="JsonObject_Indexer_Tests.cpp" />
|
||||||
<ClCompile Include="JsonObject_PrintTo_Tests.cpp" />
|
<ClCompile Include="JsonObject_PrintTo_Tests.cpp" />
|
||||||
<ClCompile Include="JsonValueTests.cpp" />
|
<ClCompile Include="JsonValueTests.cpp" />
|
||||||
<ClCompile Include="StringBuilderTests.cpp" />
|
<ClCompile Include="StringBuilderTests.cpp" />
|
||||||
|
@ -30,5 +30,8 @@
|
|||||||
<ClCompile Include="JsonObject_PrintTo_Tests.cpp">
|
<ClCompile Include="JsonObject_PrintTo_Tests.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="JsonObject_Indexer_Tests.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
42
JsonGeneratorTests/JsonObject_Indexer_Tests.cpp
Normal file
42
JsonGeneratorTests/JsonObject_Indexer_Tests.cpp
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
Reference in New Issue
Block a user