Files
ArduinoJson/JsonGeneratorTests/JsonObject_Indexer_Tests.cpp

52 lines
1.1 KiB
C++
Raw Normal View History

2014-08-01 14:35:54 +02:00
/*
* 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)
2014-08-01 14:35:54 +02:00
{
mustNotContain("key");
}
2014-08-01 14:35:54 +02:00
TEST_METHOD(OneString)
{
object["key"] = "value";
mustContain("key", "value");
}
private:
void mustContain(const char* key, const char* expected)
{
2014-08-02 16:11:02 +02:00
Assert::IsTrue(object.containsKey(key));
const char* actual = object[key];
2014-08-01 14:35:54 +02:00
Assert::AreEqual(expected, actual);
}
void mustNotContain(const char* key)
{
2014-08-02 16:11:02 +02:00
Assert::IsFalse(object.containsKey(key));
const char* actual = object[key];
Assert::IsNull(actual);
}
2014-08-01 14:35:54 +02:00
};
}