main.cpp 924 B

12345678910111213141516171819202122232425262728293031323334
  1. #define CR_HOST
  2. #include <gtest/gtest.h>
  3. #include <common/boxed_type.h>
  4. #include <common/empty.h>
  5. #include <cr.h>
  6. #include <entt/entity/entity.hpp>
  7. #include <entt/entity/registry.hpp>
  8. TEST(Lib, Registry) {
  9. constexpr auto count = 3;
  10. entt::registry registry;
  11. for(auto i = 0; i < count; ++i) {
  12. const auto entity = registry.create();
  13. registry.emplace<test::boxed_int>(entity, i);
  14. }
  15. cr_plugin ctx;
  16. cr_plugin_load(ctx, PLUGIN);
  17. ctx.userdata = &registry;
  18. cr_plugin_update(ctx);
  19. ASSERT_EQ(registry.storage<test::boxed_int>().size(), registry.storage<test::empty>().size());
  20. ASSERT_EQ(registry.storage<test::boxed_int>().size(), registry.storage<entt::entity>().size());
  21. registry.view<test::boxed_int>().each([count](auto entity, auto &elem) {
  22. ASSERT_EQ(elem.value, entt::to_integral(entity) + count);
  23. });
  24. registry = {};
  25. cr_plugin_close(ctx);
  26. }