main.cpp 890 B

123456789101112131415161718192021222324252627282930313233
  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/registry.hpp>
  7. TEST(Lib, Registry) {
  8. constexpr auto count = 3;
  9. entt::registry registry;
  10. for(auto i = 0; i < count; ++i) {
  11. const auto entity = registry.create();
  12. registry.emplace<test::boxed_int>(entity, i);
  13. }
  14. cr_plugin ctx;
  15. cr_plugin_load(ctx, PLUGIN);
  16. ctx.userdata = &registry;
  17. cr_plugin_update(ctx);
  18. ASSERT_EQ(registry.storage<test::boxed_int>().size(), registry.storage<test::empty>().size());
  19. ASSERT_EQ(registry.storage<test::boxed_int>().size(), registry.storage<entt::entity>().size());
  20. registry.view<test::boxed_int>().each([count](auto entity, auto &elem) {
  21. ASSERT_EQ(elem.value, entt::to_integral(entity) + count);
  22. });
  23. registry = {};
  24. cr_plugin_close(ctx);
  25. }