main.cpp 833 B

123456789101112131415161718192021222324252627
  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. }