Add more tests with VLAs

This commit is contained in:
Benoit Blanchon
2024-11-07 14:19:47 +01:00
parent 1110d62128
commit 31253dbe13
7 changed files with 160 additions and 2 deletions

View File

@ -34,6 +34,21 @@ TEST_CASE("JsonDocument::operator[]") {
REQUIRE((doc["hello"] | "nope") == "world"_s);
REQUIRE((doc["world"] | "nope") == "nope"_s);
}
#if defined(HAS_VARIABLE_LENGTH_ARRAY) && \
!defined(SUBSCRIPT_CONFLICTS_WITH_BUILTIN_OPERATOR)
SECTION("supports VLAs") {
size_t i = 16;
char vla[i];
strcpy(vla, "hello");
doc[vla] = "world";
REQUIRE(doc[vla] == "world");
REQUIRE(cdoc[vla] == "world");
REQUIRE(doc.as<std::string>() == "{\"hello\":\"world\"}");
}
#endif
}
SECTION("array") {