SerializableJSONIntegerTest.cpp 1.1 KB

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