SerializableSectionPairDocumentTest.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-16
  6. * Changed: 2023-02-16
  7. *
  8. * */
  9. #include <gtest/gtest.h>
  10. #include <ls-std-io-test.hpp>
  11. #include <ls-std/ls-std-core.hpp>
  12. #include <ls-std/ls-std-io.hpp>
  13. #include <memory>
  14. using namespace ls::std::core;
  15. using namespace ls::std::core::type;
  16. using namespace ls::std::io;
  17. using namespace ::std;
  18. using namespace test::io;
  19. namespace
  20. {
  21. class SerializableSectionPairDocumentTest : public ::testing::Test
  22. {
  23. protected:
  24. SerializableSectionPairDocumentTest() = default;
  25. ~SerializableSectionPairDocumentTest() override = default;
  26. void SetUp() override
  27. {}
  28. void TearDown() override
  29. {}
  30. };
  31. TEST_F(SerializableSectionPairDocumentTest, constructor_no_value)
  32. {
  33. EXPECT_THROW(
  34. {
  35. try
  36. {
  37. SerializableSectionPairDocument serializable = SerializableSectionPairDocument(nullptr);
  38. }
  39. catch (const IllegalArgumentException &_exception)
  40. {
  41. throw;
  42. }
  43. },
  44. IllegalArgumentException);
  45. }
  46. TEST_F(SerializableSectionPairDocumentTest, getValue)
  47. {
  48. SerializableSectionPairDocument serializable(make_shared<SectionPairDocument>());
  49. ASSERT_TRUE(serializable.getValue() != nullptr);
  50. }
  51. TEST_F(SerializableSectionPairDocumentTest, marshal)
  52. {
  53. SerializableSectionPairDocument serializable(SectionPairDocumentProvider::createDocument());
  54. byte_field expected = SectionPairDocumentProvider::createSerializedDocument();
  55. ASSERT_STREQ(expected.c_str(), serializable.marshal().c_str());
  56. }
  57. TEST_F(SerializableSectionPairDocumentTest, unmarshal)
  58. {
  59. SerializableSectionPairDocument serializable(make_shared<SectionPairDocument>());
  60. serializable.unmarshal(SectionPairDocumentProvider::createSerializedDocument());
  61. shared_ptr<SectionPairDocument> expected = SectionPairDocumentProvider::createDocument();
  62. ASSERT_EQ(2, expected->getAmountOfSections());
  63. }
  64. }