SerializableJSONStringTest.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-30
  6. * Changed: 2020-08-30
  7. *
  8. * */
  9. #include <gtest/gtest.h>
  10. #include "../../../../source/boxing/String.hpp"
  11. #include "../../../../source/serialization/boxing/SerializableJSONString.hpp"
  12. namespace {
  13. class SerializableJSONStringTest : public ::testing::Test {
  14. protected:
  15. SerializableJSONStringTest() = default;
  16. ~SerializableJSONStringTest() override = default;
  17. void SetUp() override {}
  18. void TearDown() override {}
  19. };
  20. TEST_F(SerializableJSONStringTest, marshal)
  21. {
  22. ls_std::String x {"Testing something!"};
  23. ls_std::SerializableJSONString serializable {std::make_shared<ls_std::String>(x)};
  24. ls_std::byte_field content = serializable.marshal();
  25. ASSERT_STREQ(R"({"class":"String","value":"Testing something!"})", content.c_str());
  26. }
  27. TEST_F(SerializableJSONStringTest, unmarshal)
  28. {
  29. std::shared_ptr<ls_std::String> x = std::make_shared<ls_std::String>("Hello!");
  30. ASSERT_STREQ("Hello!", *x);
  31. ls_std::SerializableJSONString serializable {x};
  32. serializable.unmarshal(R"({"class":"String","value":"Ups!"})");
  33. ASSERT_STREQ("Ups!", *x);
  34. }
  35. }