main.cpp 828 B

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