Explorar o código

test: enforce requirements for non default constructible components (close #405)

Michele Caini %!s(int64=6) %!d(string=hai) anos
pai
achega
43503e2fc9
Modificáronse 1 ficheiros con 13 adicións e 3 borrados
  1. 13 3
      test/entt/entity/registry.cpp

+ 13 - 3
test/entt/entity/registry.cpp

@@ -11,6 +11,11 @@
 
 struct empty_type {};
 
+struct non_default_constructible {
+    non_default_constructible(int i): i{i} {}
+    int i;
+};
+
 struct listener {
     template<typename Component>
     static void sort(entt::registry &registry) {
@@ -1492,10 +1497,15 @@ TEST(Registry, BatchCreateAmbiguousCall) {
 }
 
 TEST(Registry, MoveOnlyComponent) {
-    // the purpose is to ensure that move only components are always accepted
     entt::registry registry;
-    const auto entity = registry.create();
-    registry.assign<std::unique_ptr<int>>(entity);
+    // the purpose is to ensure that move only types are always accepted
+    registry.assign<std::unique_ptr<int>>(registry.create());
+}
+
+TEST(Registry, NonDefaultConstructibleComponent) {
+    entt::registry registry;
+    // the purpose is to ensure that non default constructible type are always accepted
+    registry.assign<non_default_constructible>(registry.create(), 42);
 }
 
 TEST(Registry, Dependencies) {