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

@ -11,9 +11,20 @@ TEST_CASE("JsonObject::get()") {
DynamicJsonDocument doc;
JsonObject obj = doc.to<JsonObject>();
SECTION("GetConstCharPointer_GivenStringLiteral") {
SECTION("get<const char*>(const char*)") {
obj.set("hello", "world");
const char* value = obj.get<const char*>("hello");
REQUIRE_THAT(value, Equals("world"));
}
#ifdef HAS_VARIABLE_LENGTH_ARRAY
SECTION("get<const char*>(VLA)") {
obj.set("hello", "world");
int i = 16;
char vla[i];
strcpy(vla, "hello");
REQUIRE(std::string("world") == obj.get<char*>(vla));
}
#endif
}