2014-10-23 23:39:22 +02:00
|
|
|
// Copyright Benoit Blanchon 2014
|
|
|
|
// MIT License
|
|
|
|
//
|
|
|
|
// Arduino JSON library
|
|
|
|
// https://github.com/bblanchon/ArduinoJson
|
|
|
|
|
2014-10-22 21:56:38 +02:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <ArduinoJson/JsonObject.hpp>
|
|
|
|
#include <ArduinoJson/StaticJsonBuffer.hpp>
|
|
|
|
|
|
|
|
using namespace ArduinoJson;
|
|
|
|
|
2014-10-23 19:54:00 +02:00
|
|
|
TEST(JsonObject_Iterator_Test, SimpleTest) {
|
|
|
|
StaticJsonBuffer<42> jsonBuffer;
|
2014-10-22 21:56:38 +02:00
|
|
|
|
2014-10-23 19:54:00 +02:00
|
|
|
JsonObject object = jsonBuffer.createObject();
|
|
|
|
object["ab"] = 12;
|
|
|
|
object["cd"] = 34;
|
2014-10-22 21:56:38 +02:00
|
|
|
|
2014-10-24 18:53:03 +02:00
|
|
|
JsonObject::iterator it = object.begin();
|
|
|
|
JsonObject::iterator end = object.end();
|
2014-10-22 21:56:38 +02:00
|
|
|
|
2014-10-23 19:54:00 +02:00
|
|
|
EXPECT_NE(end, it);
|
|
|
|
EXPECT_STREQ("ab", it->key());
|
|
|
|
EXPECT_EQ(12, it->value().as<int>());
|
|
|
|
++it;
|
|
|
|
EXPECT_NE(end, it);
|
|
|
|
EXPECT_STREQ("cd", it->key());
|
|
|
|
EXPECT_EQ(34, it->value().as<int>());
|
|
|
|
++it;
|
|
|
|
EXPECT_EQ(object.end(), it);
|
2014-10-23 23:45:36 +02:00
|
|
|
}
|