SectionPairSectionIdUnmarshalValidatorTest.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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-17
  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. using namespace ::std;
  16. namespace
  17. {
  18. class SectionPairSectionIdUnmarshalValidatorTest : public ::testing::Test
  19. {
  20. protected:
  21. SectionPairSectionIdUnmarshalValidatorTest() = default;
  22. ~SectionPairSectionIdUnmarshalValidatorTest() override = default;
  23. void SetUp() override
  24. {}
  25. void TearDown() override
  26. {}
  27. };
  28. TEST_F(SectionPairSectionIdUnmarshalValidatorTest, getClassName)
  29. {
  30. ASSERT_STREQ("SectionPairSectionIdUnmarshalValidator", SectionPairSectionIdUnmarshalValidator("\n[general]\n", NewLine::get()).getClassName().c_str());
  31. }
  32. TEST_F(SectionPairSectionIdUnmarshalValidatorTest, isValid)
  33. {
  34. string newLine = NewLine::get();
  35. byte_field generalSection = newLine + "[general]" + newLine + newLine;
  36. byte_field localServerSection = newLine + "[local-server]" + newLine + newLine;
  37. ASSERT_TRUE(SectionPairSectionIdUnmarshalValidator(generalSection, newLine).isValid());
  38. ASSERT_TRUE(SectionPairSectionIdUnmarshalValidator(localServerSection, newLine).isValid());
  39. }
  40. TEST_F(SectionPairSectionIdUnmarshalValidatorTest, isValid_not_valid)
  41. {
  42. string newLine = NewLine::get();
  43. byte_field generalSection = newLine + "[general]" + newLine;
  44. byte_field localServerSection = newLine + "[local-server]";
  45. byte_field position = newLine + "position" + newLine;
  46. ASSERT_FALSE(SectionPairSectionIdUnmarshalValidator(generalSection, newLine).isValid());
  47. ASSERT_FALSE(SectionPairSectionIdUnmarshalValidator(localServerSection, newLine).isValid());
  48. ASSERT_FALSE(SectionPairSectionIdUnmarshalValidator(position, newLine).isValid());
  49. }
  50. }