@@ -7,7 +7,7 @@ struct custom_entity_traits {
7
7
using entity_type = std::uint32_t ;
8
8
using version_type = std::uint16_t ;
9
9
static constexpr entity_type entity_mask = 0x3FFFF ; // 18b
10
- static constexpr entity_type version_mask = 0x3FFF ; // 14b
10
+ static constexpr entity_type version_mask = 0x0FFF ; // 12b
11
11
};
12
12
13
13
template <>
@@ -57,6 +57,41 @@ TYPED_TEST(Entity, Traits) {
57
57
58
58
ASSERT_EQ (traits_type::next (entt::tombstone), traits_type::construct (entt::null, {}));
59
59
ASSERT_EQ (traits_type::next (entt::null), traits_type::construct (entt::null, {}));
60
+
61
+ if constexpr (traits_type::to_integral (tombstone) != ~traits_type::entity_type{}) {
62
+ // test reserved bits, if any
63
+ constexpr entity_type reserved{traits_type::to_integral (entity) | (traits_type::to_integral (tombstone) + 1u )};
64
+
65
+ ASSERT_NE (reserved, entity);
66
+
67
+ ASSERT_NE (traits_type::to_integral (null), ~traits_type::entity_type{});
68
+ ASSERT_NE (traits_type::to_integral (tombstone), ~traits_type::entity_type{});
69
+
70
+ ASSERT_EQ (traits_type::to_entity (reserved), traits_type::to_entity (entity));
71
+ ASSERT_EQ (traits_type::to_version (reserved), traits_type::to_version (entity));
72
+
73
+ ASSERT_EQ (traits_type::to_version (null), traits_type::version_mask);
74
+ ASSERT_EQ (traits_type::to_version (tombstone), traits_type::version_mask);
75
+
76
+ ASSERT_EQ (traits_type::to_version (traits_type::next (null)), 0u );
77
+ ASSERT_EQ (traits_type::to_version (traits_type::next (tombstone)), 0u );
78
+
79
+ ASSERT_EQ (traits_type::construct (traits_type::to_integral (entity), traits_type::version_mask + 1u ), entity_type{traits_type::to_entity (entity)});
80
+
81
+ ASSERT_EQ (traits_type::construct (traits_type::to_integral (null), traits_type::to_version (null) + 1u ), entity_type{traits_type::to_entity (null)});
82
+ ASSERT_EQ (traits_type::construct (traits_type::to_integral (tombstone), traits_type::to_version (tombstone) + 1u ), entity_type{traits_type::to_entity (tombstone)});
83
+
84
+ ASSERT_EQ (traits_type::next (reserved), traits_type::next (entity));
85
+
86
+ ASSERT_EQ (traits_type::next (null), traits_type::combine (null, entity_type{}));
87
+ ASSERT_EQ (traits_type::next (tombstone), traits_type::combine (tombstone, entity_type{}));
88
+
89
+ ASSERT_EQ (traits_type::combine (entity, reserved), entity);
90
+ ASSERT_NE (traits_type::combine (entity, reserved), reserved);
91
+
92
+ ASSERT_EQ (traits_type::combine (reserved, entity), entity);
93
+ ASSERT_NE (traits_type::combine (reserved, entity), reserved);
94
+ }
60
95
}
61
96
62
97
TYPED_TEST (Entity, Null) {
0 commit comments