main.cpp 721 B

123456789101112131415161718192021222324
  1. #include <gtest/gtest.h>
  2. #include "common/boxed_type.h"
  3. #include <entt/core/attribute.h>
  4. #include <entt/locator/locator.hpp>
  5. ENTT_API void set_up(const entt::locator<test::boxed_int>::node_type &);
  6. ENTT_API void use_service(int);
  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. set_up(entt::locator<test::boxed_int>::handle());
  11. use_service(3);
  12. ASSERT_EQ(entt::locator<test::boxed_int>::value().value, 3);
  13. // service updates do not propagate across boundaries
  14. entt::locator<test::boxed_int>::emplace().value = 4;
  15. use_service(3);
  16. ASSERT_EQ(entt::locator<test::boxed_int>::value().value, 4);
  17. }