SerializableJSONIntegerTest.cpp 1.2 KB

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