2017-01-06 21:07:34 +01:00
|
|
|
// Copyright Benoit Blanchon 2014-2017
|
2015-09-28 22:14:50 +02:00
|
|
|
// MIT License
|
|
|
|
//
|
|
|
|
// Arduino JSON library
|
2017-03-25 22:05:06 +01:00
|
|
|
// https://bblanchon.github.io/ArduinoJson/
|
2016-01-07 22:35:12 +01:00
|
|
|
// If you like this project, please add a star!
|
2015-09-28 22:14:50 +02:00
|
|
|
|
|
|
|
#include <ArduinoJson.h>
|
2017-04-18 18:22:24 +02:00
|
|
|
#include <catch.hpp>
|
2015-09-28 22:14:50 +02:00
|
|
|
|
2017-04-18 18:22:24 +02:00
|
|
|
TEST_CASE("JsonArray basics") {
|
|
|
|
DynamicJsonBuffer jb;
|
|
|
|
JsonArray& array = jb.createArray();
|
2015-09-28 22:14:50 +02:00
|
|
|
|
2017-04-18 18:22:24 +02:00
|
|
|
SECTION("SuccessIsTrue") {
|
|
|
|
REQUIRE(array.success());
|
|
|
|
}
|
2015-09-28 22:14:50 +02:00
|
|
|
|
2017-04-18 18:22:24 +02:00
|
|
|
SECTION("InitialSizeIsZero") {
|
|
|
|
REQUIRE(0U == array.size());
|
|
|
|
}
|
2015-09-28 22:14:50 +02:00
|
|
|
|
2017-04-18 18:22:24 +02:00
|
|
|
SECTION("CreateNestedArray") {
|
|
|
|
JsonArray& arr = array.createNestedArray();
|
|
|
|
REQUIRE(&arr == &array[0].as<JsonArray&>());
|
|
|
|
}
|
2015-09-28 22:14:50 +02:00
|
|
|
|
2017-04-18 18:22:24 +02:00
|
|
|
SECTION("CreateNestedObject") {
|
|
|
|
JsonObject& obj = array.createNestedObject();
|
|
|
|
REQUIRE(&obj == &array[0].as<JsonObject&>());
|
|
|
|
}
|
2015-09-28 22:14:50 +02:00
|
|
|
}
|