SectionPairSectionIdUnmarshalValidatorTest.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-14
  6. * Changed: 2023-02-15
  7. *
  8. * */
  9. #include <gtest/gtest.h>
  10. #include <ls-std/ls-std-core.hpp>
  11. #include <ls-std/ls-std-io.hpp>
  12. using namespace ls::std::core;
  13. using namespace ls::std::core::type;
  14. using namespace ls::std::io;
  15. namespace
  16. {
  17. class SectionPairSectionIdUnmarshalValidatorTest : public ::testing::Test
  18. {
  19. protected:
  20. SectionPairSectionIdUnmarshalValidatorTest() = default;
  21. ~SectionPairSectionIdUnmarshalValidatorTest() override = default;
  22. void SetUp() override
  23. {}
  24. void TearDown() override
  25. {}
  26. };
  27. TEST_F(SectionPairSectionIdUnmarshalValidatorTest, getClassName)
  28. {
  29. ASSERT_STREQ("SectionPairSectionIdUnmarshalValidator", SectionPairSectionIdUnmarshalValidator{"\n[general]\n"}.getClassName().c_str());
  30. }
  31. TEST_F(SectionPairSectionIdUnmarshalValidatorTest, isValid)
  32. {
  33. byte_field generalSection = NewLine::get() + "[general]" + NewLine::get();
  34. byte_field localServerSection = NewLine::get() + "[local-server]" + NewLine::get();
  35. ASSERT_TRUE(SectionPairSectionIdUnmarshalValidator{generalSection}.isValid());
  36. ASSERT_TRUE(SectionPairSectionIdUnmarshalValidator{localServerSection}.isValid());
  37. }
  38. TEST_F(SectionPairSectionIdUnmarshalValidatorTest, isValid_not_valid)
  39. {
  40. byte_field generalSection = "[general]" + NewLine::get();
  41. byte_field localServerSection = NewLine::get() + "[local-server]";
  42. byte_field position = NewLine::get() + "position" + NewLine::get();
  43. ASSERT_FALSE(SectionPairSectionIdUnmarshalValidator{generalSection}.isValid());
  44. ASSERT_FALSE(SectionPairSectionIdUnmarshalValidator{localServerSection}.isValid());
  45. ASSERT_FALSE(SectionPairSectionIdUnmarshalValidator{position}.isValid());
  46. }
  47. }