SectionPairDocumentValidatorTest.cpp 2.8 KB

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