SerializableJSONLongTest.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-26
  6. * Changed: 2020-08-26
  7. *
  8. * */
  9. #include <gtest/gtest.h>
  10. #include "../../../../source/boxing/Long.hpp"
  11. #include "../../../../source/serialization/boxing/SerializableJSONLong.hpp"
  12. namespace {
  13. class SerializableJSONLongTest : public ::testing::Test {
  14. protected:
  15. SerializableJSONLongTest() = default;
  16. ~SerializableJSONLongTest() override = default;
  17. void SetUp() override {}
  18. void TearDown() override {}
  19. };
  20. TEST_F(SerializableJSONLongTest, marshal)
  21. {
  22. ls_std::Long x {(ls_std::long_type) 31983771009271};
  23. ls_std::SerializableJSONLong serializable {std::make_shared<ls_std::Long>(x)};
  24. ls_std::byte_field content = serializable.marshal();
  25. ASSERT_STREQ(R"({"class":"Long","value":31983771009271})", content.c_str());
  26. }
  27. TEST_F(SerializableJSONLongTest, unmarshal)
  28. {
  29. std::shared_ptr<ls_std::Long> x = std::make_shared<ls_std::Long>(31983771009271);
  30. ASSERT_EQ(31983771009271, *x);
  31. ls_std::SerializableJSONLong serializable {x};
  32. serializable.unmarshal(R"({"class":"Long","value":1989})");
  33. ASSERT_EQ(1989, *x);
  34. }
  35. }