🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
833 B

  1. #include <gtest/gtest.h>
  2. #include <entt/core/attribute.h>
  3. #include <entt/entity/entity.hpp>
  4. #include <entt/entity/registry.hpp>
  5. #include "types.h"
  6. ENTT_API void update_position(entt::registry &);
  7. ENTT_API void emplace_velocity(entt::registry &);
  8. TEST(Lib, Registry) {
  9. entt::registry registry;
  10. for(auto i = 0; i < 3; ++i) {
  11. const auto entity = registry.create();
  12. registry.emplace<position>(entity, i, i);
  13. }
  14. emplace_velocity(registry);
  15. update_position(registry);
  16. ASSERT_EQ(registry.storage<position>().size(), registry.storage<velocity>().size());
  17. registry.view<position>().each([](auto entity, auto &position) {
  18. ASSERT_EQ(position.x, static_cast<int>(entt::to_integral(entity) + 16));
  19. ASSERT_EQ(position.y, static_cast<int>(entt::to_integral(entity) + 16));
  20. });
  21. }