main.cpp 1015 B

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