source: rtos_arduino/trunk/arduino_lib/libraries/ArduinoJson/test/JsonObject_Iterator_Tests.cpp@ 209

Last change on this file since 209 was 209, checked in by ertl-honda, 8 years ago

BlueMix用のフィアルを追加

File size: 1.4 KB
Line 
1// Copyright Benoit Blanchon 2014-2016
2// MIT License
3//
4// Arduino JSON library
5// https://github.com/bblanchon/ArduinoJson
6// If you like this project, please add a star!
7
8#include <gtest/gtest.h>
9#include <ArduinoJson.h>
10
11class JsonObject_Iterator_Test : public testing::Test {
12 public:
13 JsonObject_Iterator_Test() : _object(_buffer.createObject()) {
14 _object["ab"] = 12;
15 _object["cd"] = 34;
16 }
17
18 protected:
19 StaticJsonBuffer<JSON_OBJECT_SIZE(2)> _buffer;
20 JsonObject& _object;
21};
22
23TEST_F(JsonObject_Iterator_Test, NonConstIterator) {
24 JsonObject::iterator it = _object.begin();
25 ASSERT_NE(_object.end(), it);
26 EXPECT_STREQ("ab", it->key);
27 EXPECT_EQ(12, it->value);
28 it->key = "a.b";
29 it->value = 1.2;
30 ++it;
31 ASSERT_NE(_object.end(), it);
32 EXPECT_STREQ("cd", it->key);
33 EXPECT_EQ(34, it->value);
34 it->key = "c.d";
35 it->value = 3.4;
36 ++it;
37 ASSERT_EQ(_object.end(), it);
38
39 ASSERT_EQ(2, _object.size());
40 EXPECT_EQ(1.2, _object["a.b"]);
41 EXPECT_EQ(3.4, _object["c.d"]);
42}
43
44TEST_F(JsonObject_Iterator_Test, ConstIterator) {
45 const JsonObject& const_object = _object;
46 JsonObject::const_iterator it = const_object.begin();
47
48 ASSERT_NE(const_object.end(), it);
49 EXPECT_STREQ("ab", it->key);
50 EXPECT_EQ(12, it->value);
51 ++it;
52 ASSERT_NE(const_object.end(), it);
53 EXPECT_STREQ("cd", it->key);
54 EXPECT_EQ(34, it->value);
55 ++it;
56 ASSERT_EQ(const_object.end(), it);
57}
Note: See TracBrowser for help on using the repository browser.