main.cpp 828 B

123456789101112131415161718192021222324252627282930313233
  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+1);
  11. }
  12. ASSERT_FALSE(registry.empty<position>());
  13. ASSERT_TRUE(registry.empty<velocity>());
  14. cr_plugin ctx;
  15. ctx.userdata = &registry;
  16. cr_plugin_load(ctx, PLUGIN);
  17. cr_plugin_update(ctx);
  18. ASSERT_FALSE(registry.empty<position>());
  19. ASSERT_FALSE(registry.empty<velocity>());
  20. registry.view<position>().each([](auto entity, auto &position) {
  21. ASSERT_EQ(position.x, entt::to_integer(entity) + 2);
  22. ASSERT_EQ(position.y, entt::to_integer(entity) + 3);
  23. });
  24. cr_plugin_close(ctx);
  25. }