SectionPairDocumentValidatorTest.cpp 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Co-Author: Claude Sonnet 4.6 (LLM)
  4. * Company: Lynar Studios
  5. * E-Mail: webmaster@lynarstudios.com
  6. * Created: 2023-02-21
  7. * Changed: 2026-06-23
  8. *
  9. * */
  10. #include <gtest/gtest.h>
  11. #include <ls-std-io-test.hpp>
  12. #include <ls-std/ls-std-core.hpp>
  13. #include <ls-std/ls-std-io.hpp>
  14. #include <string>
  15. using ls::standard::io::NewLine;
  16. using ls::standard::io::SectionPairDocumentValidator;
  17. using std::string;
  18. using test::io::SectionPairDocumentProvider;
  19. using testing::Test;
  20. using testing::TestWithParam;
  21. using testing::Values;
  22. namespace
  23. {
  24. class SectionPairDocumentValidatorTest : public Test
  25. {
  26. public:
  27. SectionPairDocumentValidatorTest() = default;
  28. ~SectionPairDocumentValidatorTest() override = default;
  29. };
  30. class SectionPairDocumentValidatorTest_LineBreakTest : public TestWithParam<string>
  31. {
  32. public:
  33. SectionPairDocumentValidatorTest_LineBreakTest() = default;
  34. ~SectionPairDocumentValidatorTest_LineBreakTest() override = default;
  35. };
  36. class SectionPairDocumentValidatorTest_ValidArgumentTest : public TestWithParam<string>
  37. {
  38. public:
  39. SectionPairDocumentValidatorTest_ValidArgumentTest() = default;
  40. ~SectionPairDocumentValidatorTest_ValidArgumentTest() override = default;
  41. };
  42. class SectionPairDocumentValidatorTest_InvalidArgumentTest : public TestWithParam<string>
  43. {
  44. public:
  45. SectionPairDocumentValidatorTest_InvalidArgumentTest() = default;
  46. ~SectionPairDocumentValidatorTest_InvalidArgumentTest() override = default;
  47. };
  48. TEST_F(SectionPairDocumentValidatorTest, getClassName)
  49. {
  50. ASSERT_STREQ("SectionPairDocumentValidator", SectionPairDocumentValidator{"tmp-key"}.getClassName().c_str());
  51. }
  52. TEST_P(SectionPairDocumentValidatorTest_LineBreakTest, isValid)
  53. {
  54. ASSERT_TRUE(SectionPairDocumentValidator{GetParam()}.isValid());
  55. }
  56. TEST_P(SectionPairDocumentValidatorTest_ValidArgumentTest, isValid)
  57. {
  58. ASSERT_TRUE(SectionPairDocumentValidator{GetParam()}.isValid());
  59. }
  60. TEST_P(SectionPairDocumentValidatorTest_InvalidArgumentTest, isValid_not_valid)
  61. {
  62. ASSERT_FALSE(SectionPairDocumentValidator{GetParam()}.isValid());
  63. }
  64. INSTANTIATE_TEST_SUITE_P(LineBreakTest, SectionPairDocumentValidatorTest_LineBreakTest, Values(SectionPairDocumentProvider::createSerializedDocument(NewLine::getWindowsNewLine()), SectionPairDocumentProvider::createSerializedDocument(NewLine::getUnixNewLine())));
  65. INSTANTIATE_TEST_SUITE_P(InvalidArgumentTest, SectionPairDocumentValidatorTest_InvalidArgumentTest, Values("\n[general]\n\ncolors:\nblue\n"));
  66. INSTANTIATE_TEST_SUITE_P(ValidArgumentTest, SectionPairDocumentValidatorTest_ValidArgumentTest, Values(SectionPairDocumentProvider::createSerializedDocumentComputerExample(NewLine::get()), SectionPairDocumentProvider::createSerializedDocumentColineExample(NewLine::get())));
  67. }