Fixed duplication of char*

This commit is contained in:
Benoit Blanchon
2018-08-22 14:37:17 +02:00
parent 7683667b3c
commit 6d290bd001
25 changed files with 601 additions and 531 deletions

View File

@ -93,4 +93,29 @@ TEST_CASE("JsonVariant::operator[]") {
REQUIRE(std::string("world") == var["hello"]);
}
}
#if defined(HAS_VARIABLE_LENGTH_ARRAY) && \
!defined(SUBSCRIPT_CONFLICTS_WITH_BUILTIN_OPERATOR)
SECTION("key is a VLA") {
int i = 16;
char vla[i];
strcpy(vla, "hello");
deserializeJson(doc, "{\"hello\":\"world\"}");
JsonVariant variant = doc.as<JsonVariant>();
REQUIRE(std::string("world") == variant[vla]);
}
SECTION("key is a VLA, const JsonVariant") {
int i = 16;
char vla[i];
strcpy(vla, "hello");
deserializeJson(doc, "{\"hello\":\"world\"}");
const JsonVariant variant = doc.as<JsonVariant>();
REQUIRE(std::string("world") == variant[vla]);
}
#endif
}