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

@ -32,6 +32,18 @@ TEST_CASE("MemberProxy::add()") {
REQUIRE(doc.as<std::string>() == "{\"hello\":[\"world\"]}");
}
#ifdef HAS_VARIABLE_LENGTH_ARRAY
SECTION("add(vla)") {
size_t i = 16;
char vla[i];
strcpy(vla, "world");
mp.add(vla);
REQUIRE(doc.as<std::string>() == "{\"hello\":[\"world\"]}");
}
#endif
}
TEST_CASE("MemberProxy::clear()") {
@ -195,6 +207,18 @@ TEST_CASE("MemberProxy::set()") {
REQUIRE(doc.as<std::string>() == "{\"hello\":\"world\"}");
}
#ifdef HAS_VARIABLE_LENGTH_ARRAY
SECTION("set(vla)") {
size_t i = 8;
char vla[i];
strcpy(vla, "world");
mp.set(vla);
REQUIRE(doc.as<std::string>() == "{\"hello\":\"world\"}");
}
#endif
}
TEST_CASE("MemberProxy::size()") {