main.cpp 715 B

1234567891011121314151617181920212223242526272829
  1. #define CR_HOST
  2. #include <cr.h>
  3. #include <gtest/gtest.h>
  4. #include <entt/entity/registry.hpp>
  5. #include "types.h"
  6. TEST(Lib, Registry) {
  7. entt::registry registry;
  8. for(auto i = 0; i < 3; ++i) {
  9. const auto entity = registry.create();
  10. registry.assign<position>(entity, i, i);
  11. }
  12. cr_plugin ctx;
  13. ctx.userdata = &registry;
  14. cr_plugin_load(ctx, PLUGIN);
  15. cr_plugin_update(ctx);
  16. ASSERT_EQ(registry.size<position>(), registry.size<velocity>());
  17. registry.view<position>().each([](auto entity, auto &position) {
  18. ASSERT_EQ(position.x, entt::to_integral(entity) + 16);
  19. ASSERT_EQ(position.y, entt::to_integral(entity) + 16);
  20. });
  21. cr_plugin_close(ctx);
  22. }