Files
ArduinoJson/test/JsonObject_Iterator_Tests.cpp

33 lines
753 B
C++
Raw Normal View History

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) {
2014-10-30 21:51:59 +01:00
StaticJsonBuffer<256> jsonBuffer;
2014-10-22 21:56:38 +02:00
2014-10-30 10:49:02 +01:00
JsonObject &object = jsonBuffer.createObject();
2014-10-23 19:54:00 +02:00
object["ab"] = 12;
object["cd"] = 34;
2014-10-22 21:56:38 +02:00
JsonObject::iterator it = object.begin();
JsonObject::iterator end = object.end();
2014-10-22 21:56:38 +02:00
2014-10-30 21:51:59 +01:00
ASSERT_NE(end, it);
2014-10-30 10:49:02 +01:00
EXPECT_STREQ("ab", it->key);
EXPECT_EQ(12, it->value.as<int>());
2014-10-23 19:54:00 +02:00
++it;
2014-10-30 21:51:59 +01:00
ASSERT_NE(end, it);
2014-10-30 10:49:02 +01:00
EXPECT_STREQ("cd", it->key);
EXPECT_EQ(34, it->value.as<int>());
2014-10-23 19:54:00 +02:00
++it;
EXPECT_EQ(object.end(), it);
2014-10-23 23:45:36 +02:00
}