test: avoid moving trivially copyable types

This commit is contained in:
Michele Caini
2023-12-20 09:19:19 +01:00
parent cbf853fa75
commit 6b608f51fb
6 changed files with 9 additions and 14 deletions

View File

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

View File

@@ -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);

View File

@@ -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*());

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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) {