SectionPairDocumentValidatorTest.cpp 2.7 KB

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