Replace JsonString::Ownership with bool

This commit is contained in:
Benoit Blanchon
2024-11-26 14:32:29 +01:00
parent 8931651317
commit ed5f890d28
9 changed files with 23 additions and 23 deletions
+2 -2
View File
@@ -158,7 +158,7 @@ TEST_CASE("JsonObject::operator[]") {
}
SECTION("should duplicate a non-static JsonString key") {
obj[JsonString("hello", JsonString::Copied)] = "world";
obj[JsonString("hello", false)] = "world";
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofPool()),
Allocate(sizeofString("hello")),
@@ -166,7 +166,7 @@ TEST_CASE("JsonObject::operator[]") {
}
SECTION("should not duplicate a static JsonString key") {
obj[JsonString("hello", JsonString::Linked)] = "world";
obj[JsonString("hello", true)] = "world";
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofPool()),
});
+2 -2
View File
@@ -132,7 +132,7 @@ TEST_CASE("JsonVariant::set() when there is enough memory") {
char str[16];
strcpy(str, "hello");
bool result = variant.set(JsonString(str, JsonString::Linked));
bool result = variant.set(JsonString(str, true));
strcpy(str, "world");
REQUIRE(result == true);
@@ -144,7 +144,7 @@ TEST_CASE("JsonVariant::set() when there is enough memory") {
char str[16];
strcpy(str, "hello");
bool result = variant.set(JsonString(str, JsonString::Copied));
bool result = variant.set(JsonString(str));
strcpy(str, "world");
REQUIRE(result == true);
+2 -2
View File
@@ -101,7 +101,7 @@ TEST_CASE("adaptString()") {
}
SECTION("JsonString linked") {
JsonString orig("hello", JsonString::Ownership::Linked);
JsonString orig("hello", true);
auto s = adaptString(orig);
CHECK(s.isNull() == false);
@@ -110,7 +110,7 @@ TEST_CASE("adaptString()") {
}
SECTION("JsonString copied") {
JsonString orig("hello", JsonString::Ownership::Copied);
JsonString orig("hello", false);
auto s = adaptString(orig);
CHECK(s.isNull() == false);
@@ -139,8 +139,7 @@ TEST_CASE("serialize MsgPack value") {
SECTION("str 32") {
std::string shortest(65536, '?');
checkVariant(JsonString(shortest.c_str(),
JsonString::Linked), // force store by pointer
checkVariant(JsonString(shortest.c_str(), true), // force store by pointer
"\xDB\x00\x01\x00\x00"_s + shortest);
}