Fix call of overloaded 'String(const char*, int)' is ambiguous

This commit is contained in:
Benoit Blanchon
2022-02-17 10:47:42 +01:00
parent ef8379df1b
commit a880614a75
15 changed files with 47 additions and 31 deletions

View File

@ -141,13 +141,13 @@ TEST_CASE("JsonObject::operator[]") {
}
SECTION("should duplicate a non-static JsonString key") {
obj[JsonString("hello", false)] = "world";
obj[JsonString("hello", JsonString::Copied)] = "world";
const size_t expectedSize = JSON_OBJECT_SIZE(1) + JSON_STRING_SIZE(5);
REQUIRE(expectedSize == doc.memoryUsage());
}
SECTION("should not duplicate a static JsonString key") {
obj[JsonString("hello", true)] = "world";
obj[JsonString("hello", JsonString::Linked)] = "world";
const size_t expectedSize = JSON_OBJECT_SIZE(1);
REQUIRE(expectedSize == doc.memoryUsage());
}

View File

@ -136,7 +136,7 @@ TEST_CASE("JsonVariant::as()") {
REQUIRE(variant.as<long>() == 42L);
REQUIRE(variant.as<JsonString>() == "42");
REQUIRE(variant.as<JsonString>().isStatic() == true);
REQUIRE(variant.as<JsonString>().isLinked() == true);
}
SECTION("set(\"hello\")") {
@ -159,7 +159,7 @@ TEST_CASE("JsonVariant::as()") {
REQUIRE(variant.as<const char*>() == std::string("4.2"));
REQUIRE(variant.as<std::string>() == std::string("4.2"));
REQUIRE(variant.as<JsonString>() == "4.2");
REQUIRE(variant.as<JsonString>().isStatic() == false);
REQUIRE(variant.as<JsonString>().isLinked() == false);
}
SECTION("set(\"true\")") {

View File

@ -98,7 +98,7 @@ TEST_CASE("JsonVariant::set() when there is enough memory") {
char str[16];
strcpy(str, "hello");
bool result = variant.set(JsonString(str, true));
bool result = variant.set(JsonString(str, JsonString::Linked));
strcpy(str, "world");
REQUIRE(result == true);
@ -109,7 +109,7 @@ TEST_CASE("JsonVariant::set() when there is enough memory") {
char str[16];
strcpy(str, "hello");
bool result = variant.set(JsonString(str, false));
bool result = variant.set(JsonString(str, JsonString::Copied));
strcpy(str, "world");
REQUIRE(result == true);

View File

@ -13,7 +13,7 @@ TEST_CASE("JsonString") {
CHECK(s.isNull() == true);
CHECK(s.c_str() == 0);
CHECK(s.isStatic() == true);
CHECK(s.isLinked() == true);
}
SECTION("Compare null with boolean") {
@ -82,4 +82,11 @@ TEST_CASE("JsonString") {
ss << JsonString("hello world!");
CHECK(ss.str() == "hello world!");
}
SECTION("Construct with a size") {
JsonString s("hello world", 5);
CHECK(s.size() == 5);
CHECK(s.isLinked() == true);
}
}