|
|
@@ -36,18 +36,141 @@ TEST(BasicHandle, Construction) {
|
|
|
|
|
|
ASSERT_EQ(handle, chandle);
|
|
|
|
|
|
- static_assert(std::is_same_v<entt::registry &, decltype(handle.registry())>);
|
|
|
- static_assert(std::is_same_v<const entt::registry &, decltype(chandle.registry())>);
|
|
|
+ static_assert(std::is_same_v<entt::registry *, decltype(handle.registry())>);
|
|
|
+ static_assert(std::is_same_v<const entt::registry *, decltype(chandle.registry())>);
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
- handle = entt::null;
|
|
|
+TEST(BasicHandle, Invalidation) {
|
|
|
+ entt::handle handle;
|
|
|
|
|
|
+ ASSERT_TRUE(nullptr == handle.registry());
|
|
|
ASSERT_TRUE(entt::null == handle.entity());
|
|
|
- ASSERT_NE(entity, handle);
|
|
|
ASSERT_FALSE(handle);
|
|
|
|
|
|
- ASSERT_NE(handle, chandle);
|
|
|
+ entt::registry registry;
|
|
|
+ const auto entity = registry.create();
|
|
|
+
|
|
|
+ handle = {registry, entity};
|
|
|
+
|
|
|
+ ASSERT_FALSE(nullptr == handle.registry());
|
|
|
+ ASSERT_FALSE(entt::null == handle.entity());
|
|
|
+ ASSERT_TRUE(handle);
|
|
|
+
|
|
|
+ handle = {};
|
|
|
+
|
|
|
+ ASSERT_TRUE(nullptr == handle.registry());
|
|
|
+ ASSERT_TRUE(entt::null == handle.entity());
|
|
|
+ ASSERT_FALSE(handle);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+TEST(BasicHandle, Comparison) {
|
|
|
+ entt::registry registry;
|
|
|
+ const auto entity1 = registry.create();
|
|
|
+ const auto entity2 = registry.create();
|
|
|
+
|
|
|
+ entt::handle handle1{registry, entity1};
|
|
|
+ entt::handle handle2{registry, entity2};
|
|
|
+ entt::const_handle chandle1 = handle1;
|
|
|
+ entt::const_handle chandle2 = handle2;
|
|
|
+
|
|
|
+ ASSERT_NE(handle1, handle2);
|
|
|
+ ASSERT_FALSE(handle1 == handle2);
|
|
|
+ ASSERT_TRUE(handle1 != handle2);
|
|
|
+
|
|
|
+ ASSERT_NE(chandle1, chandle2);
|
|
|
+ ASSERT_FALSE(chandle1 == chandle2);
|
|
|
+ ASSERT_TRUE(chandle1 != chandle2);
|
|
|
+
|
|
|
+ ASSERT_EQ(handle1, chandle1);
|
|
|
+ ASSERT_TRUE(handle1 == chandle1);
|
|
|
+ ASSERT_FALSE(handle1 != chandle1);
|
|
|
+
|
|
|
+ ASSERT_EQ(handle2, chandle2);
|
|
|
+ ASSERT_TRUE(handle2 == chandle2);
|
|
|
+ ASSERT_FALSE(handle2 != chandle2);
|
|
|
+
|
|
|
+ ASSERT_NE(handle1, chandle2);
|
|
|
+ ASSERT_FALSE(handle1 == chandle2);
|
|
|
+ ASSERT_TRUE(handle1 != chandle2);
|
|
|
+
|
|
|
+ handle1 = {};
|
|
|
+ chandle2 = {};
|
|
|
+
|
|
|
+ ASSERT_NE(handle1, handle2);
|
|
|
+ ASSERT_FALSE(handle1 == handle2);
|
|
|
+ ASSERT_TRUE(handle1 != handle2);
|
|
|
+
|
|
|
+ ASSERT_NE(chandle1, chandle2);
|
|
|
+ ASSERT_FALSE(chandle1 == chandle2);
|
|
|
+ ASSERT_TRUE(chandle1 != chandle2);
|
|
|
+
|
|
|
+ ASSERT_NE(handle1, chandle1);
|
|
|
+ ASSERT_FALSE(handle1 == chandle1);
|
|
|
+ ASSERT_TRUE(handle1 != chandle1);
|
|
|
+
|
|
|
+ ASSERT_NE(handle2, chandle2);
|
|
|
+ ASSERT_FALSE(handle2 == chandle2);
|
|
|
+ ASSERT_TRUE(handle2 != chandle2);
|
|
|
+
|
|
|
+ ASSERT_EQ(handle1, chandle2);
|
|
|
+ ASSERT_TRUE(handle1 == chandle2);
|
|
|
+ ASSERT_FALSE(handle1 != chandle2);
|
|
|
+
|
|
|
+ handle2 = {};
|
|
|
+ chandle1 = {};
|
|
|
+
|
|
|
+ ASSERT_EQ(handle1, handle2);
|
|
|
+ ASSERT_TRUE(handle1 == handle2);
|
|
|
+ ASSERT_FALSE(handle1 != handle2);
|
|
|
+
|
|
|
+ ASSERT_EQ(chandle1, chandle2);
|
|
|
+ ASSERT_TRUE(chandle1 == chandle2);
|
|
|
+ ASSERT_FALSE(chandle1 != chandle2);
|
|
|
+
|
|
|
+ ASSERT_EQ(handle1, chandle1);
|
|
|
+ ASSERT_TRUE(handle1 == chandle1);
|
|
|
+ ASSERT_FALSE(handle1 != chandle1);
|
|
|
+
|
|
|
+ ASSERT_EQ(handle2, chandle2);
|
|
|
+ ASSERT_TRUE(handle2 == chandle2);
|
|
|
+ ASSERT_FALSE(handle2 != chandle2);
|
|
|
+
|
|
|
+ ASSERT_EQ(handle1, chandle2);
|
|
|
+ ASSERT_TRUE(handle1 == chandle2);
|
|
|
+ ASSERT_FALSE(handle1 != chandle2);
|
|
|
+
|
|
|
+ entt::registry registry_b;
|
|
|
+ const auto entity_b1 = registry.create();
|
|
|
+
|
|
|
+ handle1 = {registry_b, entity_b1};
|
|
|
+ handle2 = {registry, entity1};
|
|
|
+ chandle1 = handle1;
|
|
|
+ chandle2 = handle2;
|
|
|
+
|
|
|
+ ASSERT_NE(handle1, handle2);
|
|
|
+ ASSERT_FALSE(handle1 == handle2);
|
|
|
+ ASSERT_TRUE(handle1 != handle2);
|
|
|
+
|
|
|
+ ASSERT_NE(chandle1, chandle2);
|
|
|
+ ASSERT_FALSE(chandle1 == chandle2);
|
|
|
+ ASSERT_TRUE(chandle1 != chandle2);
|
|
|
+
|
|
|
+ ASSERT_EQ(handle1, chandle1);
|
|
|
+ ASSERT_TRUE(handle1 == chandle1);
|
|
|
+ ASSERT_FALSE(handle1 != chandle1);
|
|
|
+
|
|
|
+ ASSERT_EQ(handle2, chandle2);
|
|
|
+ ASSERT_TRUE(handle2 == chandle2);
|
|
|
+ ASSERT_FALSE(handle2 != chandle2);
|
|
|
+
|
|
|
+ ASSERT_NE(handle1, chandle2);
|
|
|
+ ASSERT_FALSE(handle1 == chandle2);
|
|
|
+ ASSERT_TRUE(handle1 != chandle2);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
TEST(BasicHandle, Component) {
|
|
|
entt::registry registry;
|
|
|
const auto entity = registry.create();
|