Added JsonArrayConst, JsonObjectConst, and JsonVariantConst

This commit is contained in:
Benoit Blanchon
2018-10-12 12:00:27 +02:00
parent d1003ff6c9
commit b0560cbd99
47 changed files with 1909 additions and 1063 deletions

View File

@ -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>());
}
}