test: merge no-eto tests with registry tests
This commit is contained in:
@@ -210,7 +210,6 @@ SETUP_BASIC_TEST(helper entt/entity/helper.cpp)
|
||||
SETUP_BASIC_TEST(observer entt/entity/observer.cpp)
|
||||
SETUP_BASIC_TEST(organizer entt/entity/organizer.cpp)
|
||||
SETUP_BASIC_TEST(registry entt/entity/registry.cpp)
|
||||
SETUP_BASIC_TEST(registry_no_eto entt/entity/registry_no_eto.cpp ENTT_NO_ETO)
|
||||
SETUP_BASIC_TEST(runtime_view entt/entity/runtime_view.cpp)
|
||||
SETUP_BASIC_TEST(sigh_storage_mixin entt/entity/sigh_storage_mixin.cpp)
|
||||
SETUP_BASIC_TEST(snapshot entt/entity/snapshot.cpp)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
#include <gtest/gtest.h>
|
||||
#include <entt/config/config.h>
|
||||
#include <entt/core/hashed_string.hpp>
|
||||
#include <entt/core/type_info.hpp>
|
||||
#include <entt/entity/entity.hpp>
|
||||
@@ -14,6 +15,14 @@
|
||||
|
||||
struct empty_type {};
|
||||
|
||||
struct no_eto_type {
|
||||
static constexpr std::size_t page_size = ENTT_PACKED_PAGE;
|
||||
};
|
||||
|
||||
bool operator==(const no_eto_type &lhs, const no_eto_type &rhs) {
|
||||
return &lhs == &rhs;
|
||||
}
|
||||
|
||||
struct stable_type {
|
||||
static constexpr auto in_place_delete = true;
|
||||
int value;
|
||||
@@ -2032,3 +2041,20 @@ TEST(Registry, StorageProxyIterator) {
|
||||
ASSERT_EQ(cit, registry.storage().begin());
|
||||
ASSERT_NE(cit, std::as_const(registry).storage().end());
|
||||
}
|
||||
|
||||
TEST(Registry, NoEtoType) {
|
||||
entt::registry registry;
|
||||
const auto entity = registry.create();
|
||||
|
||||
registry.emplace<no_eto_type>(entity);
|
||||
registry.emplace<int>(entity, 42);
|
||||
|
||||
ASSERT_NE(registry.storage<no_eto_type>().raw(), nullptr);
|
||||
ASSERT_NE(registry.try_get<no_eto_type>(entity), nullptr);
|
||||
ASSERT_EQ(registry.view<no_eto_type>().get(entity), std::as_const(registry).view<const no_eto_type>().get(entity));
|
||||
|
||||
auto view = registry.view<no_eto_type, int>();
|
||||
auto cview = std::as_const(registry).view<const no_eto_type, const int>();
|
||||
|
||||
ASSERT_EQ((std::get<0>(view.get<no_eto_type, int>(entity))), (std::get<0>(cview.get<const no_eto_type, const int>(entity))));
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
#include <gtest/gtest.h>
|
||||
#include <entt/entity/registry.hpp>
|
||||
|
||||
struct empty_type {};
|
||||
|
||||
bool operator==(const empty_type &lhs, const empty_type &rhs) {
|
||||
return &lhs == &rhs;
|
||||
}
|
||||
|
||||
TEST(Registry, NoEto) {
|
||||
entt::registry registry;
|
||||
const auto entity = registry.create();
|
||||
|
||||
registry.emplace<empty_type>(entity);
|
||||
registry.emplace<int>(entity, 42);
|
||||
|
||||
ASSERT_NE(registry.storage<empty_type>().raw(), nullptr);
|
||||
ASSERT_NE(registry.try_get<empty_type>(entity), nullptr);
|
||||
ASSERT_EQ(registry.view<empty_type>().get(entity), std::as_const(registry).view<const empty_type>().get(entity));
|
||||
|
||||
auto view = registry.view<empty_type, int>();
|
||||
auto cview = std::as_const(registry).view<const empty_type, const int>();
|
||||
|
||||
ASSERT_EQ((std::get<0>(view.get<empty_type, int>(entity))), (std::get<0>(cview.get<const empty_type, const int>(entity))));
|
||||
}
|
||||
Reference in New Issue
Block a user