Ver Fonte

Allocate slot before key

Benoit Blanchon há 1 ano atrás
pai
commit
386105be90

+ 1 - 1
extras/tests/JsonDocument/MemberProxy.cpp

@@ -358,7 +358,7 @@ TEST_CASE("MemberProxy under memory constraints") {
     REQUIRE(doc.size() == 0);
     REQUIRE(doc.overflowed() == true);
     REQUIRE(spy.log() == AllocatorLog{
-                             AllocateFail(sizeofString("hello")),
+                             AllocateFail(sizeofPool()),
                          });
   }
 }

+ 3 - 3
extras/tests/JsonDocument/assignment.cpp

@@ -22,8 +22,8 @@ TEST_CASE("JsonDocument assignment") {
     REQUIRE(doc2.as<std::string>() == "{\"hello\":\"world\"}");
 
     REQUIRE(spyingAllocator.log() == AllocatorLog{
-                                         Allocate(sizeofString("hello")),
                                          Allocate(sizeofPool()),
+                                         Allocate(sizeofString("hello")),
                                          Allocate(sizeofString("world")),
                                      });
   }
@@ -54,8 +54,8 @@ TEST_CASE("JsonDocument assignment") {
 
     REQUIRE(doc2.as<std::string>() == "{\"hello\":\"world\"}");
     REQUIRE(spyingAllocator.log() == AllocatorLog{
-                                         Allocate(sizeofString("hello")),
                                          Allocate(sizeofPool()),
+                                         Allocate(sizeofString("hello")),
                                          Allocate(sizeofString("world")),
                                      });
   }
@@ -72,8 +72,8 @@ TEST_CASE("JsonDocument assignment") {
       REQUIRE(doc1.as<std::string>() == "null");
     }
     REQUIRE(spyingAllocator.log() == AllocatorLog{
-                                         Allocate(sizeofString("hello")),
                                          Allocate(sizeofPool()),
+                                         Allocate(sizeofString("hello")),
                                          Allocate(sizeofString("world")),
                                          Deallocate(sizeofString("hello")),
                                          Deallocate(sizeofString("world")),

+ 1 - 1
extras/tests/JsonDocument/shrinkToFit.cpp

@@ -122,8 +122,8 @@ TEST_CASE("JsonDocument::shrinkToFit()") {
     REQUIRE(doc.as<std::string>() == "{\"abcdefg\":42}");
     REQUIRE(spyingAllocator.log() ==
             AllocatorLog{
-                Allocate(sizeofString("abcdefg")),
                 Allocate(sizeofPool()),
+                Allocate(sizeofString("abcdefg")),
                 Reallocate(sizeofPool(), sizeofObject(1)),
             });
   }

+ 3 - 3
extras/tests/JsonObject/set.cpp

@@ -52,8 +52,8 @@ TEST_CASE("JsonObject::set()") {
     REQUIRE(success == true);
     REQUIRE(obj2["hello"] == "world"_s);
     REQUIRE(spy.log() == AllocatorLog{
-                             Allocate(sizeofString("hello")),
                              Allocate(sizeofPool()),
+                             Allocate(sizeofString("hello")),
                          });
   }
 
@@ -66,8 +66,8 @@ TEST_CASE("JsonObject::set()") {
     REQUIRE(success == true);
     REQUIRE(obj2["hello"] == "world"_s);
     REQUIRE(spy.log() == AllocatorLog{
-                             Allocate(sizeofString("hello")),
                              Allocate(sizeofPool()),
+                             Allocate(sizeofString("hello")),
                              Allocate(sizeofString("world")),
                          });
   }
@@ -81,8 +81,8 @@ TEST_CASE("JsonObject::set()") {
     REQUIRE(success == true);
     REQUIRE(obj2["hello"] == "world"_s);
     REQUIRE(spy.log() == AllocatorLog{
-                             Allocate(sizeofString("hello")),
                              Allocate(sizeofPool()),
+                             Allocate(sizeofString("hello")),
                              Allocate(sizeofString("world")),
                          });
   }

+ 5 - 5
extras/tests/JsonObject/subscript.cpp

@@ -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")),
                          });
   }