SerializableJsonBooleanTest.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-09-04
  6. * Changed: 2021-05-02
  7. *
  8. * */
  9. #include <gtest/gtest.h>
  10. #include <ls_std/ls_std.hpp>
  11. namespace
  12. {
  13. class SerializableJsonBooleanTest : public ::testing::Test
  14. {
  15. protected:
  16. SerializableJsonBooleanTest() = default;
  17. ~SerializableJsonBooleanTest() override = default;
  18. void SetUp() override
  19. {}
  20. void TearDown() override
  21. {}
  22. };
  23. TEST_F(SerializableJsonBooleanTest, marshal)
  24. {
  25. ls_std::Boolean x{true};
  26. ls_std::SerializableJsonBoolean serializable{std::make_shared<ls_std::Boolean>(x)};
  27. ls_std::String jsonString{serializable.marshal()};
  28. ASSERT_TRUE(jsonString.contains(R"({"value":true)"));
  29. }
  30. TEST_F(SerializableJsonBooleanTest, unmarshal)
  31. {
  32. std::shared_ptr<ls_std::Boolean> x = std::make_shared<ls_std::Boolean>(false);
  33. ASSERT_FALSE(*x);
  34. ls_std::SerializableJsonBoolean serializable{x};
  35. serializable.unmarshal(R"({"value":true})");
  36. ASSERT_TRUE(*x);
  37. }
  38. TEST_F(SerializableJsonBooleanTest, getValue)
  39. {
  40. std::shared_ptr<ls_std::Boolean> x = std::make_shared<ls_std::Boolean>(false);
  41. ls_std::SerializableJsonBoolean serializable{x};
  42. ASSERT_TRUE(serializable.getValue() == x);
  43. }
  44. TEST_F(SerializableJsonBooleanTest, setValue)
  45. {
  46. std::shared_ptr<ls_std::Boolean> x = std::make_shared<ls_std::Boolean>(false);
  47. ls_std::SerializableJsonBoolean serializable{x};
  48. ASSERT_TRUE(serializable.getValue() == x);
  49. x = std::make_shared<ls_std::Boolean>(true);
  50. serializable.setValue(x);
  51. ASSERT_TRUE(serializable.getValue() == x);
  52. }
  53. }