Przeglądaj źródła

test: avoid using deprecated functions

Michele Caini 2 lat temu
rodzic
commit
1d9f771af3

+ 8 - 7
test/entt/entity/sigh_mixin.cpp

@@ -345,18 +345,19 @@ TYPED_TEST(SighMixin, Move) {
 
     ASSERT_TRUE(pool.empty()); // NOLINT
     ASSERT_FALSE(other.empty());
+
     ASSERT_EQ(other.type(), entt::type_id<value_type>());
-    ASSERT_EQ(pool.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
-    ASSERT_EQ(other.at(0u), entt::entity{3});                      // NOLINT
+
+    ASSERT_EQ(other.index(entt::entity{3}), 0u);
     ASSERT_EQ(other.get(entt::entity{3}), value_type{3});
 
     pool = std::move(other);
 
     ASSERT_FALSE(pool.empty());
-    ASSERT_TRUE(other.empty());              // NOLINT
-    ASSERT_EQ(pool.at(0u), entt::entity{3}); // NOLINT
+    ASSERT_TRUE(other.empty()); // NOLINT
+
+    ASSERT_EQ(pool.index(entt::entity{3}), 0u);
     ASSERT_EQ(pool.get(entt::entity{3}), value_type{3});
-    ASSERT_EQ(other.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
 
     other = entt::sigh_mixin<entt::storage<value_type>>{};
     other.bind(entt::forward_as_any(registry));
@@ -366,8 +367,8 @@ TYPED_TEST(SighMixin, Move) {
 
     ASSERT_TRUE(pool.empty()); // NOLINT
     ASSERT_FALSE(other.empty());
-    ASSERT_EQ(pool.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
-    ASSERT_EQ(other.at(0u), entt::entity{3});                      // NOLINT
+
+    ASSERT_EQ(other.index(entt::entity{3}), 0u);
     ASSERT_EQ(other.get(entt::entity{3}), value_type{3});
 
     other.clear();

+ 4 - 9
test/entt/entity/sparse_set.cpp

@@ -100,8 +100,7 @@ TYPED_TEST(SparseSet, Move) {
         ASSERT_EQ(set.policy(), policy); // NOLINT
         ASSERT_EQ(other.policy(), policy);
 
-        ASSERT_EQ(set.at(0u), static_cast<entity_type>(entt::null)); // NOLINT
-        ASSERT_EQ(other.at(0u), entity_type{42});                    // NOLINT
+        ASSERT_EQ(other.index(entity_type{42}), 0u);
 
         sparse_set_type extended{std::move(other), allocator_type{}};
 
@@ -111,8 +110,7 @@ TYPED_TEST(SparseSet, Move) {
         ASSERT_EQ(other.policy(), policy); // NOLINT
         ASSERT_EQ(extended.policy(), policy);
 
-        ASSERT_EQ(other.at(0u), static_cast<entity_type>(entt::null)); // NOLINT
-        ASSERT_EQ(extended.at(0u), entity_type{42});                   // NOLINT
+        ASSERT_EQ(extended.index(entity_type{42}), 0u);
 
         set = std::move(extended);
 
@@ -124,9 +122,7 @@ TYPED_TEST(SparseSet, Move) {
         ASSERT_EQ(other.policy(), policy);    // NOLINT
         ASSERT_EQ(extended.policy(), policy); // NOLINT
 
-        ASSERT_EQ(set.at(0u), entity_type{42});                           // NOLINT
-        ASSERT_EQ(other.at(0u), static_cast<entity_type>(entt::null));    // NOLINT
-        ASSERT_EQ(extended.at(0u), static_cast<entity_type>(entt::null)); // NOLINT
+        ASSERT_EQ(set.index(entity_type{42}), 0u);
 
         other = sparse_set_type{policy};
         other.push(entity_type{3});
@@ -138,8 +134,7 @@ TYPED_TEST(SparseSet, Move) {
         ASSERT_EQ(set.policy(), policy); // NOLINT
         ASSERT_EQ(other.policy(), policy);
 
-        ASSERT_EQ(set.at(0u), static_cast<entity_type>(entt::null)); // NOLINT
-        ASSERT_EQ(other.at(0u), entity_type{42});                    // NOLINT
+        ASSERT_EQ(other.index(entity_type{42}), 0u);
     }
 }
 

+ 4 - 13
test/entt/entity/storage.cpp

@@ -111,9 +111,7 @@ TYPED_TEST(Storage, Move) {
     ASSERT_EQ(pool.type(), entt::type_id<value_type>()); // NOLINT
     ASSERT_EQ(other.type(), entt::type_id<value_type>());
 
-    ASSERT_EQ(pool.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
-    ASSERT_EQ(other.at(0u), entt::entity{3});                      // NOLINT
-
+    ASSERT_EQ(other.index(entt::entity{3}), 0u);
     ASSERT_EQ(other.get(entt::entity{3}), value_type{3});
 
     entt::storage<value_type> extended{std::move(other), std::allocator<value_type>{}};
@@ -124,9 +122,7 @@ TYPED_TEST(Storage, Move) {
     ASSERT_EQ(other.type(), entt::type_id<value_type>()); // NOLINT
     ASSERT_EQ(extended.type(), entt::type_id<value_type>());
 
-    ASSERT_EQ(other.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
-    ASSERT_EQ(extended.at(0u), entt::entity{3});                    // NOLINT
-
+    ASSERT_EQ(extended.index(entt::entity{3}), 0u);
     ASSERT_EQ(extended.get(entt::entity{3}), value_type{3});
 
     pool = std::move(extended);
@@ -139,10 +135,7 @@ TYPED_TEST(Storage, Move) {
     ASSERT_EQ(other.type(), entt::type_id<value_type>());    // NOLINT
     ASSERT_EQ(extended.type(), entt::type_id<value_type>()); // NOLINT
 
-    ASSERT_EQ(pool.at(0u), entt::entity{3});                           // NOLINT
-    ASSERT_EQ(other.at(0u), static_cast<entt::entity>(entt::null));    // NOLINT
-    ASSERT_EQ(extended.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
-
+    ASSERT_EQ(pool.index(entt::entity{3}), 0u);
     ASSERT_EQ(pool.get(entt::entity{3}), value_type{3});
 
     other = entt::storage<value_type>{};
@@ -155,9 +148,7 @@ TYPED_TEST(Storage, Move) {
     ASSERT_EQ(pool.type(), entt::type_id<value_type>()); // NOLINT
     ASSERT_EQ(other.type(), entt::type_id<value_type>());
 
-    ASSERT_EQ(pool.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
-    ASSERT_EQ(other.at(0u), entt::entity{3});                      // NOLINT
-
+    ASSERT_EQ(other.index(entt::entity{3}), 0u);
     ASSERT_EQ(other.get(entt::entity{3}), value_type{3});
 }
 

+ 4 - 9
test/entt/entity/storage_entity.cpp

@@ -42,8 +42,7 @@ TEST(StorageEntity, Move) {
     ASSERT_EQ(pool.type(), entt::type_id<void>()); // NOLINT
     ASSERT_EQ(other.type(), entt::type_id<void>());
 
-    ASSERT_EQ(pool.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
-    ASSERT_EQ(other.at(0u), entt::entity{3});                      // NOLINT
+    ASSERT_EQ(other.index(entt::entity{3}), 0u);
 
     entt::storage<entt::entity> extended{std::move(other), std::allocator<entt::entity>{}};
 
@@ -53,8 +52,7 @@ TEST(StorageEntity, Move) {
     ASSERT_EQ(other.type(), entt::type_id<void>()); // NOLINT
     ASSERT_EQ(extended.type(), entt::type_id<void>());
 
-    ASSERT_EQ(other.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
-    ASSERT_EQ(extended.at(0u), entt::entity{3});                    // NOLINT
+    ASSERT_EQ(extended.index(entt::entity{3}), 0u);
 
     pool = std::move(extended);
 
@@ -66,9 +64,7 @@ TEST(StorageEntity, Move) {
     ASSERT_EQ(other.type(), entt::type_id<void>());    // NOLINT
     ASSERT_EQ(extended.type(), entt::type_id<void>()); // NOLINT
 
-    ASSERT_EQ(pool.at(0u), entt::entity{3});                           // NOLINT
-    ASSERT_EQ(other.at(0u), static_cast<entt::entity>(entt::null));    // NOLINT
-    ASSERT_EQ(extended.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
+    ASSERT_EQ(pool.index(entt::entity{3}), 0u);
 
     other = entt::storage<entt::entity>{};
     other.emplace(entt::entity{42});
@@ -80,8 +76,7 @@ TEST(StorageEntity, Move) {
     ASSERT_EQ(pool.type(), entt::type_id<void>()); // NOLINT
     ASSERT_EQ(other.type(), entt::type_id<void>());
 
-    ASSERT_EQ(pool.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
-    ASSERT_EQ(other.at(0u), entt::entity{3});                      // NOLINT
+    ASSERT_EQ(other.index(entt::entity{3}), 0u);
 }
 
 TEST(StorageEntity, Swap) {

+ 4 - 9
test/entt/entity/storage_no_instance.cpp

@@ -85,8 +85,7 @@ TYPED_TEST(StorageNoInstance, Move) {
     ASSERT_EQ(pool.type(), entt::type_id<value_type>()); // NOLINT
     ASSERT_EQ(other.type(), entt::type_id<value_type>());
 
-    ASSERT_EQ(pool.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
-    ASSERT_EQ(other.at(0u), entt::entity{3});                      // NOLINT
+    ASSERT_EQ(other.index(entt::entity{3}), 0u);
 
     entt::storage<value_type> extended{std::move(other), std::allocator<value_type>{}};
 
@@ -96,8 +95,7 @@ TYPED_TEST(StorageNoInstance, Move) {
     ASSERT_EQ(other.type(), entt::type_id<value_type>()); // NOLINT
     ASSERT_EQ(extended.type(), entt::type_id<value_type>());
 
-    ASSERT_EQ(other.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
-    ASSERT_EQ(extended.at(0u), entt::entity{3});                    // NOLINT
+    ASSERT_EQ(extended.index(entt::entity{3}), 0u);
 
     pool = std::move(extended);
 
@@ -109,9 +107,7 @@ TYPED_TEST(StorageNoInstance, Move) {
     ASSERT_EQ(other.type(), entt::type_id<value_type>());    // NOLINT
     ASSERT_EQ(extended.type(), entt::type_id<value_type>()); // NOLINT
 
-    ASSERT_EQ(pool.at(0u), entt::entity{3});                           // NOLINT
-    ASSERT_EQ(other.at(0u), static_cast<entt::entity>(entt::null));    // NOLINT
-    ASSERT_EQ(extended.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
+    ASSERT_EQ(pool.index(entt::entity{3}), 0u);
 
     other = entt::storage<value_type>{};
     other.emplace(entt::entity{42}, 42);
@@ -123,8 +119,7 @@ TYPED_TEST(StorageNoInstance, Move) {
     ASSERT_EQ(pool.type(), entt::type_id<value_type>()); // NOLINT
     ASSERT_EQ(other.type(), entt::type_id<value_type>());
 
-    ASSERT_EQ(pool.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
-    ASSERT_EQ(other.at(0u), entt::entity{3});                      // NOLINT
+    ASSERT_EQ(other.index(entt::entity{3}), 0u);
 }
 
 TYPED_TEST(StorageNoInstance, Swap) {