2014-07-17 13:58:30 +02:00
|
|
|
#include "CppUnitTest.h"
|
|
|
|
#include "JsonParser.h"
|
|
|
|
|
|
|
|
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
|
|
|
using namespace ArduinoJson::Parser;
|
|
|
|
|
|
|
|
|
|
|
|
namespace JsonParserTests
|
|
|
|
{
|
2014-07-18 22:40:50 +02:00
|
|
|
TEST_CLASS(JsonObjectIteratorTests)
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
TEST_METHOD(ThreeStrings)
|
|
|
|
{
|
|
|
|
char json [] = "{\"key1\":\"value1\",\"key2\":\"value2\",\"key3\":\"value3\"}";
|
|
|
|
char* expectedKeys [] = { "key1", "key2", "key3" };
|
|
|
|
char* expectedValues [] = { "value1", "value2", "value3" };
|
|
|
|
JsonParser<7> parser;
|
|
|
|
|
|
|
|
JsonHashTable a = parser.parse(json);
|
2014-07-17 13:58:30 +02:00
|
|
|
|
2014-07-18 16:10:19 +02:00
|
|
|
int index = 0;
|
|
|
|
|
2014-07-18 22:40:50 +02:00
|
|
|
for (auto i : a)
|
2014-07-17 13:58:30 +02:00
|
|
|
{
|
2014-07-18 22:40:50 +02:00
|
|
|
Assert::AreEqual(expectedKeys[index], i.key());
|
|
|
|
Assert::AreEqual(expectedValues[index], (const char*) i.value());
|
|
|
|
index++;
|
2014-07-17 13:58:30 +02:00
|
|
|
}
|
2014-07-18 22:40:50 +02:00
|
|
|
}
|
2014-07-17 13:58:30 +02:00
|
|
|
|
2014-07-18 22:40:50 +02:00
|
|
|
};
|
2014-07-17 13:58:30 +02:00
|
|
|
}
|