Files
ArduinoJson/test/JsonArray_Iterator_Tests.cpp

30 lines
635 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 17:59:59 +02:00
#include <gtest/gtest.h>
#include <ArduinoJson.h>
2014-10-22 17:59:59 +02:00
2014-10-23 19:54:00 +02:00
TEST(JsonArray_Iterator_Test, SimpleTest) {
2014-10-28 17:58:46 +01:00
StaticJsonBuffer<100> jsonBuffer;
2014-10-22 17:59:59 +02:00
2014-10-29 21:18:27 +01:00
JsonArray &array = jsonBuffer.createArray();
2014-10-23 19:54:00 +02:00
array.add(12);
array.add(34);
2014-10-22 17:59:59 +02:00
JsonArray::iterator it = array.begin();
JsonArray::iterator end = array.end();
2014-10-22 17:59:59 +02:00
2014-10-23 19:54:00 +02:00
EXPECT_NE(end, it);
2014-10-24 16:12:05 +02:00
EXPECT_EQ(12, it->as<int>());
2014-12-05 21:54:49 +01:00
EXPECT_EQ(12, (*it).as<int>());
2014-10-23 19:54:00 +02:00
++it;
EXPECT_NE(end, it);
2014-10-24 16:12:05 +02:00
EXPECT_EQ(34, it->as<int>());
2014-12-05 21:54:49 +01:00
EXPECT_EQ(34, (*it).as<int>());
2014-10-23 19:54:00 +02:00
++it;
2014-10-29 21:18:27 +01:00
EXPECT_EQ(end, it);
2014-10-23 23:45:36 +02:00
}