mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-16 20:12:16 +02:00
Added JsonArrayConst
, JsonObjectConst
, and JsonVariantConst
This commit is contained in:
@ -58,9 +58,6 @@ TEST_CASE("JsonArray::operator[]") {
|
||||
array[0] = arr2;
|
||||
|
||||
REQUIRE(arr2 == array[0].as<JsonArray>());
|
||||
REQUIRE(arr2 == array[0].as<JsonArray>()); // <- short hand
|
||||
// REQUIRE(arr2 == array[0].as<const JsonArray>());
|
||||
// REQUIRE(arr2 == array[0].as<const JsonArray>()); // <- short hand
|
||||
REQUIRE(true == array[0].is<JsonArray>());
|
||||
REQUIRE(false == array[0].is<int>());
|
||||
}
|
||||
@ -72,7 +69,6 @@ TEST_CASE("JsonArray::operator[]") {
|
||||
array[0] = obj;
|
||||
|
||||
REQUIRE(obj == array[0].as<JsonObject>());
|
||||
REQUIRE(obj == array[0].as<const JsonObject>()); // <- short hand
|
||||
REQUIRE(true == array[0].is<JsonObject>());
|
||||
REQUIRE(false == array[0].is<int>());
|
||||
}
|
||||
@ -148,3 +144,18 @@ TEST_CASE("JsonArray::operator[]") {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE("JsonArrayConst::operator[]") {
|
||||
DynamicJsonDocument doc;
|
||||
JsonArray array = doc.to<JsonArray>();
|
||||
array.add(0);
|
||||
|
||||
SECTION("int") {
|
||||
array[0] = 123;
|
||||
JsonArrayConst carr = array;
|
||||
|
||||
REQUIRE(123 == carr[0].as<int>());
|
||||
REQUIRE(true == carr[0].is<int>());
|
||||
REQUIRE(false == carr[0].is<bool>());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user