Allocate slot before key

This commit is contained in:
Benoit Blanchon
2024-08-23 15:27:46 +02:00
parent 83516e1740
commit 386105be90
5 changed files with 13 additions and 13 deletions

View File

@ -118,16 +118,16 @@ TEST_CASE("JsonObject::operator[]") {
SECTION("should duplicate char* key") {
obj[const_cast<char*>("hello")] = "world";
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofString("hello")),
Allocate(sizeofPool()),
Allocate(sizeofString("hello")),
});
}
SECTION("should duplicate char* key&value") {
obj[const_cast<char*>("hello")] = const_cast<char*>("world");
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofString("hello")),
Allocate(sizeofPool()),
Allocate(sizeofString("hello")),
Allocate(sizeofString("world")),
});
}
@ -143,16 +143,16 @@ TEST_CASE("JsonObject::operator[]") {
SECTION("should duplicate std::string key") {
obj["hello"_s] = "world";
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofString("hello")),
Allocate(sizeofPool()),
Allocate(sizeofString("hello")),
});
}
SECTION("should duplicate std::string key&value") {
obj["hello"_s] = "world"_s;
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofString("hello")),
Allocate(sizeofPool()),
Allocate(sizeofString("hello")),
Allocate(sizeofString("world")),
});
}
@ -160,8 +160,8 @@ TEST_CASE("JsonObject::operator[]") {
SECTION("should duplicate a non-static JsonString key") {
obj[JsonString("hello", JsonString::Copied)] = "world";
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofString("hello")),
Allocate(sizeofPool()),
Allocate(sizeofString("hello")),
});
}