main.cpp 956 B

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