Rev | Line | |
---|
[209] | 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 |
|
---|
| 11 | template <typename TIterator>
|
---|
| 12 | static void run_iterator_test() {
|
---|
| 13 | StaticJsonBuffer<JSON_ARRAY_SIZE(2)> jsonBuffer;
|
---|
| 14 |
|
---|
| 15 | JsonArray &array = jsonBuffer.createArray();
|
---|
| 16 | array.add(12);
|
---|
| 17 | array.add(34);
|
---|
| 18 |
|
---|
| 19 | TIterator it = array.begin();
|
---|
| 20 | TIterator end = array.end();
|
---|
| 21 |
|
---|
| 22 | EXPECT_NE(end, it);
|
---|
| 23 | EXPECT_EQ(12, it->template as<int>());
|
---|
| 24 | EXPECT_EQ(12, static_cast<int>(*it));
|
---|
| 25 | ++it;
|
---|
| 26 | EXPECT_NE(end, it);
|
---|
| 27 | EXPECT_EQ(34, it->template as<int>());
|
---|
| 28 | EXPECT_EQ(34, static_cast<int>(*it));
|
---|
| 29 | ++it;
|
---|
| 30 | EXPECT_EQ(end, it);
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | TEST(JsonArray_Iterator_Test, RunItertorToEnd) {
|
---|
| 34 | run_iterator_test<JsonArray::iterator>();
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | TEST(JsonArray_Iterator_Test, RunConstItertorToEnd) {
|
---|
| 38 | run_iterator_test<JsonArray::const_iterator>();
|
---|
| 39 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.