Sfoglia il codice sorgente

test: avoid moving trivially copyable types

Michele Caini 2 anni fa
parent
commit
6b608f51fb

+ 1 - 1
test/entt/container/dense_map.cpp

@@ -966,7 +966,7 @@ TEST(DenseMap, Indexing) {
     map[key] = 99;
 
     ASSERT_TRUE(map.contains(key));
-    ASSERT_EQ(map[std::move(key)], 99);
+    ASSERT_EQ(map[int{key}], 99);
     ASSERT_EQ(cmap.at(key), 99); // NOLINT
     ASSERT_EQ(map.at(key), 99);
 }

+ 1 - 1
test/entt/core/any.cpp

@@ -1298,7 +1298,7 @@ TEST_F(Any, ForwardAsAny) {
     int value = 42;
     auto ref = entt::forward_as_any(value);
     auto cref = entt::forward_as_any(std::as_const(value));
-    auto any = entt::forward_as_any(std::move(value));
+    auto any = entt::forward_as_any(int{value});
 
     ASSERT_TRUE(any);
     ASSERT_TRUE(ref);

+ 4 - 3
test/entt/core/iterator.cpp

@@ -6,11 +6,12 @@
 #include "../common/boxed_int.h"
 
 TEST(InputIteratorPointer, Functionalities) {
-    test::boxed_int instance{};
-    entt::input_iterator_pointer ptr{std::move(instance)};
+    entt::input_iterator_pointer ptr{test::boxed_int{0}};
+
+    ASSERT_EQ(ptr->value, 0);
+
     ptr->value = 42;
 
-    ASSERT_EQ(instance.value, 0); // NOLINT
     ASSERT_EQ(ptr->value, 42);
     ASSERT_EQ(ptr->value, (*ptr).value);
     ASSERT_EQ(ptr.operator->(), &ptr.operator*());

+ 1 - 7
test/entt/core/type_info.cpp

@@ -47,7 +47,7 @@ TEST(TypeInfo, Functionalities) {
     static_assert(std::is_copy_assignable_v<entt::type_info>, "Copy assignable type required");
     static_assert(std::is_move_assignable_v<entt::type_info>, "Move assignable type required");
 
-    entt::type_info info{std::in_place_type<int>};
+    const entt::type_info info{std::in_place_type<int>};
     entt::type_info other{std::in_place_type<void>};
 
     ASSERT_EQ(info, entt::type_info{std::in_place_type<int &>});
@@ -67,12 +67,6 @@ TEST(TypeInfo, Functionalities) {
     ASSERT_EQ(other.index(), entt::type_index<int>::value());
     ASSERT_EQ(other.hash(), entt::type_hash<int>::value());
     ASSERT_EQ(other.name(), entt::type_name<int>::value());
-
-    other = std::move(info);
-
-    ASSERT_EQ(other.index(), entt::type_index<int>::value());
-    ASSERT_EQ(other.hash(), entt::type_hash<int>::value());
-    ASSERT_EQ(other.name(), entt::type_name<int>::value());
 }
 
 TEST(TypeInfo, Order) {

+ 1 - 1
test/entt/meta/meta_any.cpp

@@ -1355,7 +1355,7 @@ TEST_F(MetaAny, ForwardAsMeta) {
     int value = 42;
     auto ref = entt::forward_as_meta(value);
     auto cref = entt::forward_as_meta(std::as_const(value));
-    auto any = entt::forward_as_meta(std::move(value));
+    auto any = entt::forward_as_meta(int{value});
 
     ASSERT_TRUE(any);
     ASSERT_TRUE(ref);

+ 1 - 1
test/entt/resource/resource_cache.cpp

@@ -376,8 +376,8 @@ TEST(ResourceCache, Indexing) {
     cache.load("resource"_hs, 99);
 
     ASSERT_TRUE(cache.contains("resource"_hs));
-    ASSERT_EQ(cache[std::move("resource"_hs)], 99);
     ASSERT_EQ(std::as_const(cache)["resource"_hs], 99);
+    ASSERT_EQ(cache["resource"_hs], 99);
 }
 
 TEST(ResourceCache, LoaderDispatching) {