|
|
@@ -4,6 +4,7 @@
|
|
|
#include <entt/entity/entity.hpp>
|
|
|
#include <entt/entity/registry.hpp>
|
|
|
#include <entt/entity/runtime_view.hpp>
|
|
|
+#include "../common/linter.hpp"
|
|
|
#include "../common/pointer_stable.h"
|
|
|
|
|
|
template<typename Type>
|
|
|
@@ -21,6 +22,8 @@ TYPED_TEST(RuntimeView, Functionalities) {
|
|
|
entt::registry registry;
|
|
|
runtime_view_type view{};
|
|
|
|
|
|
+ ASSERT_FALSE(view);
|
|
|
+
|
|
|
const auto e0 = registry.create();
|
|
|
const auto e1 = registry.create();
|
|
|
|
|
|
@@ -35,6 +38,7 @@ TYPED_TEST(RuntimeView, Functionalities) {
|
|
|
|
|
|
view.iterate(registry.storage<int>()).iterate(registry.storage<char>());
|
|
|
|
|
|
+ ASSERT_TRUE(view);
|
|
|
ASSERT_EQ(view.size_hint(), 0u);
|
|
|
|
|
|
registry.emplace<char>(e0);
|
|
|
@@ -78,19 +82,26 @@ TYPED_TEST(RuntimeView, Constructors) {
|
|
|
entt::registry registry;
|
|
|
runtime_view_type view{};
|
|
|
|
|
|
+ ASSERT_FALSE(view);
|
|
|
+
|
|
|
const auto entity = registry.create();
|
|
|
registry.emplace<int>(entity);
|
|
|
|
|
|
view = runtime_view_type{std::allocator<int>{}};
|
|
|
view.iterate(registry.storage<int>());
|
|
|
|
|
|
+ ASSERT_TRUE(view);
|
|
|
ASSERT_TRUE(view.contains(entity));
|
|
|
|
|
|
runtime_view_type temp{view, view.get_allocator()};
|
|
|
const runtime_view_type other{std::move(temp), view.get_allocator()};
|
|
|
|
|
|
+ test::is_initialized(temp);
|
|
|
+
|
|
|
+ ASSERT_FALSE(temp);
|
|
|
+ ASSERT_TRUE(other);
|
|
|
+
|
|
|
ASSERT_TRUE(view.contains(entity));
|
|
|
- ASSERT_FALSE(temp.contains(entity)); // NOLINT
|
|
|
ASSERT_TRUE(other.contains(entity));
|
|
|
}
|
|
|
|
|
|
@@ -100,16 +111,19 @@ TYPED_TEST(RuntimeView, Copy) {
|
|
|
entt::registry registry;
|
|
|
runtime_view_type view{};
|
|
|
|
|
|
+ ASSERT_FALSE(view);
|
|
|
+
|
|
|
const auto entity = registry.create();
|
|
|
registry.emplace<int>(entity);
|
|
|
registry.emplace<char>(entity);
|
|
|
|
|
|
view.iterate(registry.storage<int>());
|
|
|
|
|
|
- ASSERT_TRUE(view.contains(entity));
|
|
|
-
|
|
|
runtime_view_type other{view};
|
|
|
|
|
|
+ ASSERT_TRUE(view);
|
|
|
+ ASSERT_TRUE(other);
|
|
|
+
|
|
|
ASSERT_TRUE(view.contains(entity));
|
|
|
ASSERT_TRUE(other.contains(entity));
|
|
|
|
|
|
@@ -120,6 +134,9 @@ TYPED_TEST(RuntimeView, Copy) {
|
|
|
|
|
|
other = view;
|
|
|
|
|
|
+ ASSERT_TRUE(view);
|
|
|
+ ASSERT_TRUE(other);
|
|
|
+
|
|
|
ASSERT_TRUE(view.contains(entity));
|
|
|
ASSERT_TRUE(other.contains(entity));
|
|
|
}
|
|
|
@@ -130,28 +147,38 @@ TYPED_TEST(RuntimeView, Move) {
|
|
|
entt::registry registry;
|
|
|
runtime_view_type view{};
|
|
|
|
|
|
+ ASSERT_FALSE(view);
|
|
|
+
|
|
|
const auto entity = registry.create();
|
|
|
registry.emplace<int>(entity);
|
|
|
registry.emplace<char>(entity);
|
|
|
|
|
|
view.iterate(registry.storage<int>());
|
|
|
|
|
|
- ASSERT_TRUE(view.contains(entity));
|
|
|
-
|
|
|
runtime_view_type other{std::move(view)};
|
|
|
|
|
|
- ASSERT_FALSE(view.contains(entity)); // NOLINT
|
|
|
+ test::is_initialized(view);
|
|
|
+
|
|
|
+ ASSERT_FALSE(view);
|
|
|
+ ASSERT_TRUE(other);
|
|
|
+
|
|
|
ASSERT_TRUE(other.contains(entity));
|
|
|
|
|
|
view = other;
|
|
|
other.iterate(registry.storage<int>()).exclude(registry.storage<char>());
|
|
|
|
|
|
+ ASSERT_TRUE(view);
|
|
|
+ ASSERT_TRUE(other);
|
|
|
+
|
|
|
ASSERT_TRUE(view.contains(entity));
|
|
|
ASSERT_FALSE(other.contains(entity));
|
|
|
|
|
|
other = std::move(view);
|
|
|
+ test::is_initialized(view);
|
|
|
+
|
|
|
+ ASSERT_FALSE(view);
|
|
|
+ ASSERT_TRUE(other);
|
|
|
|
|
|
- ASSERT_FALSE(view.contains(entity)); // NOLINT
|
|
|
ASSERT_TRUE(other.contains(entity));
|
|
|
}
|
|
|
|
|
|
@@ -162,11 +189,17 @@ TYPED_TEST(RuntimeView, Swap) {
|
|
|
runtime_view_type view{};
|
|
|
runtime_view_type other{};
|
|
|
|
|
|
+ ASSERT_FALSE(view);
|
|
|
+ ASSERT_FALSE(other);
|
|
|
+
|
|
|
const auto entity = registry.create();
|
|
|
|
|
|
registry.emplace<int>(entity);
|
|
|
view.iterate(registry.storage<int>());
|
|
|
|
|
|
+ ASSERT_TRUE(view);
|
|
|
+ ASSERT_FALSE(other);
|
|
|
+
|
|
|
ASSERT_EQ(view.size_hint(), 1u);
|
|
|
ASSERT_EQ(other.size_hint(), 0u);
|
|
|
ASSERT_TRUE(view.contains(entity));
|
|
|
@@ -176,6 +209,9 @@ TYPED_TEST(RuntimeView, Swap) {
|
|
|
|
|
|
view.swap(other);
|
|
|
|
|
|
+ ASSERT_FALSE(view);
|
|
|
+ ASSERT_TRUE(other);
|
|
|
+
|
|
|
ASSERT_EQ(view.size_hint(), 0u);
|
|
|
ASSERT_EQ(other.size_hint(), 1u);
|
|
|
ASSERT_FALSE(view.contains(entity));
|