Skip to content

Commit 7d8461b

Browse files
committed
test: non-regression test for storage iterator page size deduction
1 parent 060590b commit 7d8461b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

test/entt/entity/storage.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ struct entt::component_traits<std::unordered_set<char>> {
6767
static constexpr auto page_size = 4u;
6868
};
6969

70+
template<>
71+
struct entt::component_traits<int> {
72+
static constexpr auto in_place_delete = false;
73+
static constexpr auto page_size = 128u;
74+
};
75+
7076
template<typename Type>
7177
struct Storage: testing::Test {
7278
static_assert(entt::component_traits<Type>::page_size != 0u, "Empty type not allowed");
@@ -533,16 +539,17 @@ TYPED_TEST(Storage, IteratorPageSizeAwareness) {
533539
using traits_type = entt::component_traits<value_type>;
534540
entt::storage<value_type> pool;
535541

536-
const value_type check{2};
542+
static_assert(!std::is_same_v<value_type, int> || (traits_type::page_size != entt::component_traits<value_type *>::page_size), "Different page size required");
537543

538544
for(unsigned int next{}; next < traits_type::page_size; ++next) {
539545
pool.emplace(entt::entity{next});
540546
}
541547

542-
pool.emplace(entt::entity{traits_type::page_size}, check);
548+
pool.emplace(entt::entity{traits_type::page_size});
543549

544550
// test the proper use of component traits by the storage iterator
545-
ASSERT_EQ(*pool.begin(), check);
551+
ASSERT_EQ(&pool.begin()[0], pool.raw()[1u]);
552+
ASSERT_EQ(&pool.begin()[traits_type::page_size], pool.raw()[0u]);
546553
}
547554

548555
TYPED_TEST(Storage, Getters) {

0 commit comments

Comments
 (0)