monostate.cpp 624 B

12345678910111213141516171819202122
  1. #include <gtest/gtest.h>
  2. #include <entt/core/hashed_string.hpp>
  3. #include <entt/core/monostate.hpp>
  4. TEST(Monostate, Functionalities) {
  5. using namespace entt::literals;
  6. const bool b_pre = entt::monostate<entt::hashed_string{"foobar"}>{};
  7. const int i_pre = entt::monostate<"foobar"_hs>{};
  8. ASSERT_FALSE(b_pre);
  9. ASSERT_EQ(i_pre, int{});
  10. entt::monostate<"foobar"_hs>{} = true;
  11. entt::monostate_v<"foobar"_hs> = 2;
  12. const bool &b_post = entt::monostate<"foobar"_hs>{};
  13. const int &i_post = entt::monostate_v<entt::hashed_string{"foobar"}>;
  14. ASSERT_TRUE(b_post);
  15. ASSERT_EQ(i_post, 2);
  16. }