2018-07-12 09:08:20 +02:00
|
|
|
// ArduinoJson - arduinojson.org
|
2020-01-09 15:48:38 +01:00
|
|
|
// Copyright Benoit Blanchon 2014-2020
|
2018-07-12 09:08:20 +02:00
|
|
|
// MIT License
|
|
|
|
|
|
|
|
#include <ArduinoJson.h>
|
|
|
|
#include <catch.hpp>
|
|
|
|
|
|
|
|
TEST_CASE("JsonArray::isNull()") {
|
2018-10-12 17:59:50 +02:00
|
|
|
SECTION("returns true") {
|
|
|
|
JsonArray arr;
|
|
|
|
REQUIRE(arr.isNull() == true);
|
2018-07-12 09:08:20 +02:00
|
|
|
}
|
|
|
|
|
2018-10-12 17:59:50 +02:00
|
|
|
SECTION("returns false") {
|
2019-09-24 09:38:00 +02:00
|
|
|
DynamicJsonDocument doc(4096);
|
2018-10-12 17:59:50 +02:00
|
|
|
JsonArray arr = doc.to<JsonArray>();
|
|
|
|
REQUIRE(arr.isNull() == false);
|
|
|
|
}
|
2018-07-12 09:08:20 +02:00
|
|
|
}
|
2018-10-12 12:00:27 +02:00
|
|
|
|
|
|
|
TEST_CASE("JsonArrayConst::isNull()") {
|
2018-10-12 17:59:50 +02:00
|
|
|
SECTION("returns true") {
|
|
|
|
JsonArrayConst arr;
|
|
|
|
REQUIRE(arr.isNull() == true);
|
2018-10-12 12:00:27 +02:00
|
|
|
}
|
|
|
|
|
2018-10-12 17:59:50 +02:00
|
|
|
SECTION("returns false") {
|
2019-09-24 09:38:00 +02:00
|
|
|
DynamicJsonDocument doc(4096);
|
2018-10-12 17:59:50 +02:00
|
|
|
JsonArrayConst arr = doc.to<JsonArray>();
|
|
|
|
REQUIRE(arr.isNull() == false);
|
|
|
|
}
|
2018-10-12 12:00:27 +02:00
|
|
|
}
|
2019-09-24 09:38:00 +02:00
|
|
|
|
|
|
|
TEST_CASE("JsonArray::operator bool()") {
|
|
|
|
SECTION("returns false") {
|
|
|
|
JsonArray arr;
|
|
|
|
REQUIRE(static_cast<bool>(arr) == false);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("returns true") {
|
|
|
|
DynamicJsonDocument doc(4096);
|
|
|
|
JsonArray arr = doc.to<JsonArray>();
|
|
|
|
REQUIRE(static_cast<bool>(arr) == true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("JsonArrayConst::operator bool()") {
|
|
|
|
SECTION("returns false") {
|
|
|
|
JsonArrayConst arr;
|
|
|
|
REQUIRE(static_cast<bool>(arr) == false);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("returns true") {
|
|
|
|
DynamicJsonDocument doc(4096);
|
|
|
|
JsonArrayConst arr = doc.to<JsonArray>();
|
|
|
|
REQUIRE(static_cast<bool>(arr) == true);
|
|
|
|
}
|
|
|
|
}
|