Skip to content

Commit

Permalink
test: split storage utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
skypjack committed Oct 10, 2023
1 parent b0ad2dd commit 38f6313
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ SETUP_BASIC_TEST(snapshot entt/entity/snapshot.cpp)
SETUP_BASIC_TEST(sparse_set entt/entity/sparse_set.cpp)
SETUP_BASIC_TEST(storage entt/entity/storage.cpp)
SETUP_BASIC_TEST(storage_no_instance entt/entity/storage_no_instance.cpp)
SETUP_BASIC_TEST(storage_utility entt/entity/storage_utility.cpp)
SETUP_BASIC_TEST(view entt/entity/view.cpp)

# Test graph
Expand Down
14 changes: 0 additions & 14 deletions test/entt/entity/storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2129,20 +2129,6 @@ TEST_F(StorageOld, UsesAllocatorConstruction) {

#endif

TEST_F(StorageOld, StorageType) {
// just a bunch of static asserts to avoid regressions
testing::StaticAssertTypeEq<entt::storage_type_t<char, entt::entity>, entt::sigh_mixin<entt::basic_storage<char, entt::entity>>>();
testing::StaticAssertTypeEq<entt::storage_type_t<int>, entt::sigh_mixin<entt::storage<int>>>();
}

TEST_F(StorageOld, StorageFor) {
// just a bunch of static asserts to avoid regressions
testing::StaticAssertTypeEq<entt::storage_for_t<const double, entt::entity>, const entt::sigh_mixin<entt::basic_storage<double, entt::entity>>>();
testing::StaticAssertTypeEq<entt::storage_for_t<char, entt::entity>, entt::sigh_mixin<entt::basic_storage<char, entt::entity>>>();
testing::StaticAssertTypeEq<entt::storage_for_t<const bool>, const entt::sigh_mixin<entt::storage<bool>>>();
testing::StaticAssertTypeEq<entt::storage_for_t<int>, entt::sigh_mixin<entt::storage<int>>>();
}

TEST(StorageEntity, TypeAndPolicy) {
entt::storage<entt::entity> pool;

Expand Down
30 changes: 30 additions & 0 deletions test/entt/entity/storage_utility.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <gtest/gtest.h>
#include <entt/core/type_traits.hpp>
#include <entt/entity/storage.hpp>

template<typename Type>
struct StorageUtility: testing::Test {
using type = Type;
};

using StorageUtilityTypes = ::testing::Types<int, char, double, void>;

TYPED_TEST_SUITE(StorageUtility, StorageUtilityTypes, );

TYPED_TEST(StorageUtility, StorageType) {
using value_type = typename TestFixture::type;

// just a bunch of static asserts to avoid regressions
testing::StaticAssertTypeEq<entt::storage_type_t<value_type, entt::entity>, entt::sigh_mixin<entt::basic_storage<value_type, entt::entity>>>();
testing::StaticAssertTypeEq<entt::storage_type_t<value_type>, entt::sigh_mixin<entt::storage<value_type>>>();
}

TYPED_TEST(StorageUtility, StorageFor) {
using value_type = typename TestFixture::type;

// just a bunch of static asserts to avoid regressions
testing::StaticAssertTypeEq<entt::storage_for_t<const value_type, entt::entity>, const entt::sigh_mixin<entt::basic_storage<value_type, entt::entity>>>();
testing::StaticAssertTypeEq<entt::storage_for_t<value_type, entt::entity>, entt::sigh_mixin<entt::basic_storage<value_type, entt::entity>>>();
testing::StaticAssertTypeEq<entt::storage_for_t<const value_type>, const entt::sigh_mixin<entt::storage<value_type>>>();
testing::StaticAssertTypeEq<entt::storage_for_t<value_type>, entt::sigh_mixin<entt::storage<value_type>>>();
}

0 comments on commit 38f6313

Please sign in to comment.