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 | class JsonArray_Remove_Tests : public ::testing::Test {
|
---|
| 12 | protected:
|
---|
| 13 | JsonArray_Remove_Tests() : _array(_jsonBuffer.createArray()) {
|
---|
| 14 | _array.add("one");
|
---|
| 15 | _array.add("two");
|
---|
| 16 | _array.add("three");
|
---|
| 17 | }
|
---|
| 18 |
|
---|
| 19 | DynamicJsonBuffer _jsonBuffer;
|
---|
| 20 | JsonArray& _array;
|
---|
| 21 | };
|
---|
| 22 |
|
---|
| 23 | #define TEST_(name) TEST_F(JsonArray_Remove_Tests, name)
|
---|
| 24 |
|
---|
| 25 | TEST_(RemoveFirstElement) {
|
---|
| 26 | _array.removeAt(0);
|
---|
| 27 |
|
---|
| 28 | EXPECT_EQ(2, _array.size());
|
---|
| 29 | EXPECT_STREQ("two", _array[0]);
|
---|
| 30 | EXPECT_STREQ("three", _array[1]);
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | TEST_(RemoveMiddleElement) {
|
---|
| 34 | _array.removeAt(1);
|
---|
| 35 |
|
---|
| 36 | EXPECT_EQ(2, _array.size());
|
---|
| 37 | EXPECT_STREQ("one", _array[0]);
|
---|
| 38 | EXPECT_STREQ("three", _array[1]);
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | TEST_(RemoveLastElement) {
|
---|
| 42 | _array.removeAt(2);
|
---|
| 43 |
|
---|
| 44 | EXPECT_EQ(2, _array.size());
|
---|
| 45 | EXPECT_STREQ("one", _array[0]);
|
---|
| 46 | EXPECT_STREQ("two", _array[1]);
|
---|
| 47 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.