From 72304e67813522773579d8da166e025da82087a5 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Mon, 18 Dec 2023 14:00:04 +0100 Subject: [PATCH] test: const-correctness (and [[maybe_unused] as needed) --- test/entt/core/memory.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/entt/core/memory.cpp b/test/entt/core/memory.cpp index 38cf3b9db..7e471f8c9 100644 --- a/test/entt/core/memory.cpp +++ b/test/entt/core/memory.cpp @@ -15,7 +15,7 @@ #include "../common/tracked_memory_resource.hpp" TEST(ToAddress, Functionalities) { - std::shared_ptr shared = std::make_shared(); + const std::shared_ptr shared = std::make_shared(); auto *plain = std::addressof(*shared); ASSERT_EQ(entt::to_address(shared), plain); @@ -108,7 +108,7 @@ TEST(AllocateUnique, NoUsesAllocatorConstruction) { std::pmr::polymorphic_allocator allocator{&memory_resource}; using type = std::unique_ptr>>; - type ptr = entt::allocate_unique(allocator, 0); + [[maybe_unused]] const type ptr = entt::allocate_unique(allocator, 0); ASSERT_EQ(memory_resource.do_allocate_counter(), 1u); ASSERT_EQ(memory_resource.do_deallocate_counter(), 0u); @@ -121,7 +121,7 @@ TEST(AllocateUnique, UsesAllocatorConstruction) { std::pmr::polymorphic_allocator allocator{&memory_resource}; using type = std::unique_ptr>>; - type ptr = entt::allocate_unique(allocator, test::tracked_memory_resource::default_value); + [[maybe_unused]] const type ptr = entt::allocate_unique(allocator, test::tracked_memory_resource::default_value); ASSERT_GT(memory_resource.do_allocate_counter(), 1u); ASSERT_EQ(memory_resource.do_deallocate_counter(), 0u); @@ -215,7 +215,7 @@ TEST(MakeObjUsingAllocator, Functionalities) { TEST(UninitializedConstructUsingAllocator, NoUsesAllocatorConstruction) { alignas(int) std::byte storage[sizeof(int)]; - std::allocator allocator{}; + const std::allocator allocator{}; int *value = entt::uninitialized_construct_using_allocator(reinterpret_cast(&storage), allocator, 42); @@ -229,7 +229,7 @@ TEST(UninitializedConstructUsingAllocator, UsesAllocatorConstruction) { using string_type = typename test::tracked_memory_resource::string_type; test::tracked_memory_resource memory_resource{}; - std::pmr::polymorphic_allocator allocator{&memory_resource}; + const std::pmr::polymorphic_allocator allocator{&memory_resource}; alignas(string_type) std::byte storage[sizeof(string_type)]; string_type *value = entt::uninitialized_construct_using_allocator(reinterpret_cast(&storage), allocator, test::tracked_memory_resource::default_value);