Procházet zdrojové kódy

test: minor changes

Michele Caini před 4 roky
rodič
revize
7094d658f8

+ 2 - 0
test/entt/common/tracked_memory_resource.hpp

@@ -33,6 +33,8 @@ public:
     using string_type = std::pmr::string;
     using size_type = std::size_t;
 
+    static constexpr const char *default_value = "a string long enough to force an allocation (hopefully)";
+
     size_type do_allocate_counter() const ENTT_NOEXCEPT {
         return alloc_counter;
     }

+ 2 - 2
test/entt/core/memory.cpp

@@ -90,9 +90,9 @@ TEST(Memory, UsesAllocatorConstruction) {
 
     test::tracked_memory_resource memory_resource{};
     std::pmr::polymorphic_allocator<string_type> allocator{&memory_resource};
-    const char *str = "a string long enough to force an allocation (hopefully)";
 
-    std::unique_ptr<string_type, entt::allocation_deleter<std::pmr::polymorphic_allocator<string_type>>> ptr = entt::allocate_unique<string_type>(allocator, str);
+    using type = std::unique_ptr<string_type, entt::allocation_deleter<std::pmr::polymorphic_allocator<string_type>>>;
+    type ptr = entt::allocate_unique<string_type>(allocator, test::tracked_memory_resource::default_value);
 
     ASSERT_GT(memory_resource.do_allocate_counter(), 1u);
     ASSERT_EQ(memory_resource.do_deallocate_counter(), 0u);

+ 1 - 2
test/entt/entity/storage.cpp

@@ -1765,13 +1765,12 @@ TEST(Storage, UsesAllocatorConstruction) {
 
     test::tracked_memory_resource memory_resource{};
     entt::basic_storage<entt::entity, string_type, std::pmr::polymorphic_allocator<string_type>> pool{&memory_resource};
-    const char *str = "a string long enough to force an allocation (hopefully)";
     const entt::entity entity{};
 
     pool.emplace(entity);
     pool.erase(entity);
     memory_resource.reset();
-    pool.emplace(entity, str);
+    pool.emplace(entity, test::tracked_memory_resource::default_value);
 
     ASSERT_GT(memory_resource.do_allocate_counter(), 0u);
     ASSERT_EQ(memory_resource.do_deallocate_counter(), 0u);