Jelajahi Sumber

test: more entity types

Michele Caini 2 tahun lalu
induk
melakukan
e33d8b28ca

+ 0 - 12
test/common/custom_entity.h

@@ -1,12 +0,0 @@
-#ifndef ENTT_COMMON_CUSTOM_ENTITY_H
-#define ENTT_COMMON_CUSTOM_ENTITY_H
-
-#include <cstdint>
-
-namespace test {
-
-enum custom_entity : std::uint32_t {};
-
-} // namespace test
-
-#endif

+ 13 - 0
test/common/entity.h

@@ -0,0 +1,13 @@
+#ifndef ENTT_COMMON_ENTITY_H
+#define ENTT_COMMON_ENTITY_H
+
+#include <cstdint>
+
+namespace test {
+
+enum entity : std::uint32_t {};
+enum other_entity : std::uint32_t {};
+
+} // namespace test
+
+#endif

+ 5 - 5
test/entt/entity/entity.cpp

@@ -1,12 +1,12 @@
 #include <cstddef>
 #include <cstdint>
 #include <gtest/gtest.h>
-#include <common/custom_entity.h>
+#include <common/entity.h>
 #include <entt/config/config.h>
 #include <entt/entity/entity.hpp>
 
-struct custom_entity_traits {
-    using value_type = test::custom_entity;
+struct entity_traits {
+    using value_type = test::entity;
     using entity_type = std::uint32_t;
     using version_type = std::uint16_t;
     static constexpr entity_type entity_mask = 0x3FFFF; // 18b
@@ -14,7 +14,7 @@ struct custom_entity_traits {
 };
 
 template<>
-struct entt::entt_traits<test::custom_entity>: entt::basic_entt_traits<custom_entity_traits> {
+struct entt::entt_traits<test::entity>: entt::basic_entt_traits<entity_traits> {
     static constexpr std::size_t page_size = ENTT_SPARSE_PAGE;
 };
 
@@ -23,7 +23,7 @@ struct Entity: testing::Test {
     using type = Type;
 };
 
-using EntityTypes = ::testing::Types<entt::entity, test::custom_entity>;
+using EntityTypes = ::testing::Types<entt::entity, test::entity>;
 
 TYPED_TEST_SUITE(Entity, EntityTypes, );
 

+ 6 - 6
test/entt/entity/registry.cpp

@@ -11,8 +11,8 @@
 #include <gtest/gtest.h>
 #include <common/aggregate.h>
 #include <common/config.h>
-#include <common/custom_entity.h>
 #include <common/empty.h>
+#include <common/entity.h>
 #include <common/non_default_constructible.h>
 #include <common/pointer_stable.h>
 #include <entt/config/config.h>
@@ -79,8 +79,8 @@ private:
     bool *ctx_check{};
 };
 
-struct custom_entity_traits {
-    using value_type = test::custom_entity;
+struct entity_traits {
+    using value_type = test::entity;
     using entity_type = uint32_t;
     using version_type = uint16_t;
     static constexpr entity_type entity_mask = 0xFF;
@@ -88,7 +88,7 @@ struct custom_entity_traits {
 };
 
 template<>
-struct entt::entt_traits<test::custom_entity>: entt::basic_entt_traits<custom_entity_traits> {
+struct entt::entt_traits<test::entity>: entt::basic_entt_traits<entity_traits> {
     static constexpr auto page_size = ENTT_SPARSE_PAGE;
 };
 
@@ -758,8 +758,8 @@ TEST(Registry, CreateDestroyReleaseCornerCase) {
 }
 
 ENTT_DEBUG_TEST(RegistryDeathTest, CreateTooManyEntities) {
-    entt::basic_registry<test::custom_entity> registry{};
-    std::vector<test::custom_entity> entity(entt::entt_traits<test::custom_entity>::to_entity(entt::null));
+    entt::basic_registry<test::entity> registry{};
+    std::vector<test::entity> entity(entt::entt_traits<test::entity>::to_entity(entt::null));
     registry.create(entity.begin(), entity.end());
 
     ASSERT_DEATH([[maybe_unused]] const auto entt = registry.create(), "");

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

@@ -5,7 +5,7 @@
 #include <type_traits>
 #include <utility>
 #include <gtest/gtest.h>
-#include <common/custom_entity.h>
+#include <common/entity.h>
 #include <common/linter.hpp>
 #include <common/non_default_constructible.h>
 #include <common/pointer_stable.h>
@@ -24,11 +24,11 @@ void listener(std::size_t &counter, Registry &, typename Registry::entity_type)
     ++counter;
 }
 
-struct custom_registry: entt::basic_registry<test::custom_entity> {};
+struct custom_registry: entt::basic_registry<test::entity> {};
 
 template<typename Type>
-struct entt::storage_type<Type, test::custom_entity, std::allocator<Type>, std::enable_if_t<!std::is_same_v<Type, test::custom_entity>>> {
-    using type = entt::basic_sigh_mixin<entt::basic_storage<Type, test::custom_entity>, custom_registry>;
+struct entt::storage_type<Type, test::entity, std::allocator<Type>, std::enable_if_t<!std::is_same_v<Type, test::entity>>> {
+    using type = entt::basic_sigh_mixin<entt::basic_storage<Type, test::entity>, custom_registry>;
 };
 
 template<typename Type>
@@ -436,18 +436,18 @@ TYPED_TEST(SighMixin, Swap) {
 
 TYPED_TEST(SighMixin, CustomRegistry) {
     using value_type = typename TestFixture::type;
-    entt::basic_sigh_mixin<entt::basic_storage<value_type, test::custom_entity>, custom_registry> pool;
+    entt::basic_sigh_mixin<entt::basic_storage<value_type, test::entity>, custom_registry> pool;
     custom_registry registry;
 
     std::size_t on_construct{};
     std::size_t on_destroy{};
 
-    pool.bind(entt::forward_as_any(static_cast<entt::basic_registry<test::custom_entity> &>(registry)));
+    pool.bind(entt::forward_as_any(static_cast<entt::basic_registry<test::entity> &>(registry)));
     pool.on_construct().template connect<&listener<custom_registry>>(on_construct);
     pool.on_destroy().template connect<&listener<custom_registry>>(on_destroy);
 
-    pool.emplace(test::custom_entity{3});
-    pool.emplace(test::custom_entity{1});
+    pool.emplace(test::entity{3});
+    pool.emplace(test::entity{1});
 
     ASSERT_EQ(on_construct, 2u);
     ASSERT_EQ(on_destroy, 0u);

+ 5 - 5
test/entt/entity/sparse_set.cpp

@@ -7,7 +7,7 @@
 #include <utility>
 #include <gtest/gtest.h>
 #include <common/config.h>
-#include <common/custom_entity.h>
+#include <common/entity.h>
 #include <common/linter.hpp>
 #include <common/throwing_allocator.hpp>
 #include <entt/config/config.h>
@@ -16,8 +16,8 @@
 #include <entt/entity/entity.hpp>
 #include <entt/entity/sparse_set.hpp>
 
-struct custom_entity_traits {
-    using value_type = test::custom_entity;
+struct entity_traits {
+    using value_type = test::entity;
     using entity_type = std::uint32_t;
     using version_type = std::uint16_t;
     static constexpr entity_type entity_mask = 0x3FFFF; // 18b
@@ -25,7 +25,7 @@ struct custom_entity_traits {
 };
 
 template<>
-struct entt::entt_traits<test::custom_entity>: entt::basic_entt_traits<custom_entity_traits> {
+struct entt::entt_traits<test::entity>: entt::basic_entt_traits<entity_traits> {
     static constexpr std::size_t page_size = ENTT_SPARSE_PAGE;
 };
 
@@ -43,7 +43,7 @@ struct SparseSet: testing::Test {
 template<typename Type>
 using SparseSetDeathTest = SparseSet<Type>;
 
-using SparseSetTypes = ::testing::Types<entt::entity, test::custom_entity>;
+using SparseSetTypes = ::testing::Types<entt::entity, test::entity>;
 
 TYPED_TEST_SUITE(SparseSet, SparseSetTypes, );
 TYPED_TEST_SUITE(SparseSetDeathTest, SparseSetTypes, );