Skip to content

Commit d010720

Browse files
committed
moved dynamic test down
1 parent a38a1e1 commit d010720

File tree

1 file changed

+45
-45
lines changed

1 file changed

+45
-45
lines changed

runtime/test/runtime_test.cc

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -401,51 +401,6 @@ TEST(Core, EventCollector) {
401401
}
402402
}
403403

404-
TEST(Core, DynamicSystemImpl) {
405-
auto reg = ecsact::core::registry("DynamicSystemImpl");
406-
auto entity = reg.create_entity();
407-
auto other_entity = reg.create_entity();
408-
409-
ComponentA comp{.a = 42};
410-
reg.add_component(entity, comp);
411-
reg.add_component(other_entity, comp);
412-
413-
OtherEntityComponent other_comp{.num = 3, .target = other_entity};
414-
ASSERT_EQ(reg.add_component(entity, other_comp), ECSACT_ADD_OK);
415-
416-
// Sanity check
417-
ASSERT_TRUE(reg.has_component<ComponentA>(entity));
418-
ASSERT_EQ(reg.get_component<ComponentA>(entity), comp);
419-
ASSERT_TRUE(reg.has_component<ComponentA>(other_entity));
420-
ASSERT_EQ(reg.get_component<ComponentA>(other_entity), comp);
421-
ASSERT_TRUE(reg.has_component<OtherEntityComponent>(entity));
422-
ASSERT_EQ(reg.get_component<OtherEntityComponent>(entity), other_comp);
423-
424-
ecsact_set_system_execution_impl(
425-
ecsact_id_cast<ecsact_system_like_id>(runtime_test::SimpleSystem::id),
426-
&runtime_test__SimpleSystem
427-
);
428-
429-
ecsact_set_system_execution_impl(
430-
ecsact_id_cast<ecsact_system_like_id>(runtime_test::OtherEntitySystem::id),
431-
&runtime_test__OtherEntitySystem
432-
);
433-
434-
auto exec_err = ecsact_execute_systems(reg.id(), 1, nullptr, nullptr);
435-
ASSERT_EQ(exec_err, ECSACT_EXEC_SYS_OK);
436-
437-
// Sanity check
438-
ASSERT_TRUE(reg.has_component<ComponentA>(entity));
439-
440-
auto comp_get = reg.get_component<ComponentA>(entity);
441-
442-
EXPECT_NE(comp_get.a, comp.a);
443-
444-
// Simulate what the system should be doing.
445-
comp.a += 2;
446-
EXPECT_EQ(comp_get.a, comp.a);
447-
}
448-
449404
TEST(Core, ExecuteSystemsErrors) {
450405
auto reg = ecsact::core::registry("ExecuteSystemsErrors");
451406
auto options = ecsact_execution_options{};
@@ -627,6 +582,51 @@ TEST(Core, AssociationEntityCorrectness) {
627582
}
628583
}
629584

585+
TEST(Core, DynamicSystemImpl) {
586+
auto reg = ecsact::core::registry("DynamicSystemImpl");
587+
auto entity = reg.create_entity();
588+
auto other_entity = reg.create_entity();
589+
590+
ComponentA comp{.a = 42};
591+
reg.add_component(entity, comp);
592+
reg.add_component(other_entity, comp);
593+
594+
OtherEntityComponent other_comp{.num = 3, .target = other_entity};
595+
ASSERT_EQ(reg.add_component(entity, other_comp), ECSACT_ADD_OK);
596+
597+
// Sanity check
598+
ASSERT_TRUE(reg.has_component<ComponentA>(entity));
599+
ASSERT_EQ(reg.get_component<ComponentA>(entity), comp);
600+
ASSERT_TRUE(reg.has_component<ComponentA>(other_entity));
601+
ASSERT_EQ(reg.get_component<ComponentA>(other_entity), comp);
602+
ASSERT_TRUE(reg.has_component<OtherEntityComponent>(entity));
603+
ASSERT_EQ(reg.get_component<OtherEntityComponent>(entity), other_comp);
604+
605+
ecsact_set_system_execution_impl(
606+
ecsact_id_cast<ecsact_system_like_id>(runtime_test::SimpleSystem::id),
607+
&runtime_test__SimpleSystem
608+
);
609+
610+
ecsact_set_system_execution_impl(
611+
ecsact_id_cast<ecsact_system_like_id>(runtime_test::OtherEntitySystem::id),
612+
&runtime_test__OtherEntitySystem
613+
);
614+
615+
auto exec_err = ecsact_execute_systems(reg.id(), 1, nullptr, nullptr);
616+
ASSERT_EQ(exec_err, ECSACT_EXEC_SYS_OK);
617+
618+
// Sanity check
619+
ASSERT_TRUE(reg.has_component<ComponentA>(entity));
620+
621+
auto comp_get = reg.get_component<ComponentA>(entity);
622+
623+
EXPECT_NE(comp_get.a, comp.a);
624+
625+
// Simulate what the system should be doing.
626+
comp.a += 2;
627+
EXPECT_EQ(comp_get.a, comp.a);
628+
}
629+
630630
#ifdef ECSACT_ENTT_TEST_STATIC_SYSTEM_IMPL
631631
TEST(Core, StaticSystemImpl) {
632632
auto reg_id = ecsact_create_registry("StaticSystemImpl");

0 commit comments

Comments
 (0)