main.cpp 778 B

12345678910111213141516171819202122232425262728293031
  1. #define CR_HOST
  2. #include <gtest/gtest.h>
  3. #include "common/boxed_type.h"
  4. #include <cr.h>
  5. #include <entt/locator/locator.hpp>
  6. #include "userdata.h"
  7. TEST(Lib, Locator) {
  8. entt::locator<test::boxed_int>::emplace().value = 4;
  9. ASSERT_EQ(entt::locator<test::boxed_int>::value().value, 4);
  10. userdata ud{entt::locator<test::boxed_int>::handle(), 3};
  11. cr_plugin ctx;
  12. ctx.userdata = &ud;
  13. cr_plugin_load(ctx, PLUGIN);
  14. cr_plugin_update(ctx);
  15. ASSERT_EQ(entt::locator<test::boxed_int>::value().value, ud.value);
  16. // service updates do not propagate across boundaries
  17. entt::locator<test::boxed_int>::emplace().value = 4;
  18. cr_plugin_update(ctx);
  19. ASSERT_NE(entt::locator<test::boxed_int>::value().value, ud.value);
  20. cr_plugin_close(ctx);
  21. }