Update libs

This commit is contained in:
iranl
2024-12-03 12:20:47 +01:00
parent 8a23eb3d03
commit a14074fd6d
62 changed files with 561 additions and 190 deletions

View File

@@ -46,6 +46,18 @@ TEST_CASE("JsonVariant::add(T)") {
REQUIRE(var.as<std::string>() == "{\"val\":123}");
}
#ifdef HAS_VARIABLE_LENGTH_ARRAY
SECTION("supports VLAs") {
size_t i = 16;
char vla[i];
strcpy(vla, "hello");
var.add(vla);
REQUIRE(var.as<std::string>() == "[\"hello\"]");
}
#endif
}
TEST_CASE("JsonVariant::add<T>()") {

View File

@@ -83,6 +83,23 @@ TEST_CASE("JsonVariant::remove(std::string)") {
REQUIRE(var.as<std::string>() == "{\"a\":1}");
}
#ifdef HAS_VARIABLE_LENGTH_ARRAY
TEST_CASE("JsonVariant::remove(VLA)") {
JsonDocument doc;
JsonVariant var = doc.to<JsonVariant>();
var["a"] = 1;
var["b"] = 2;
size_t i = 16;
char vla[i];
strcpy(vla, "b");
var.remove("b"_s);
REQUIRE(var.as<std::string>() == "{\"a\":1}");
}
#endif
TEST_CASE("JsonVariant::remove(JsonVariant) from object") {
JsonDocument doc;
JsonVariant var = doc.to<JsonVariant>();

View File

@@ -99,7 +99,7 @@ TEST_CASE("vector<int>") {
}
TEST_CASE("array<int, 2>") {
typedef std::array<int, 2> array_type;
using array_type = std::array<int, 2>;
SECTION("toJson") {
array_type v;

View File

@@ -116,12 +116,19 @@ TEST_CASE("JsonVariant::operator[]") {
}
SECTION("use JsonVariant as key") {
object["a"] = "a";
object["b"] = "b";
object["c"] = "b";
object["a"] = "A";
object["ab"] = "AB";
object["ab\0c"_s] = "ABC";
object["key1"] = "a";
object["key2"] = "ab";
object["key3"] = "ab\0c"_s;
object["key4"] = "foo";
REQUIRE(var[var["c"]] == "b");
REQUIRE(var[var["d"]].isNull());
REQUIRE(var[var["key1"]] == "A");
REQUIRE(var[var["key2"]] == "AB");
REQUIRE(var[var["key3"]] == "ABC");
REQUIRE(var[var["key4"]].isNull());
REQUIRE(var[var["key5"]].isNull());
}
}