SectionPairDocumentValidatorTest.cpp 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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-22
  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 namespace ls::std::core;
  15. using namespace ls::std::io;
  16. using namespace ::std;
  17. using namespace test::io;
  18. using namespace ::testing;
  19. namespace
  20. {
  21. class SectionPairDocumentValidatorTest : public Test
  22. {
  23. protected:
  24. SectionPairDocumentValidatorTest() = default;
  25. ~SectionPairDocumentValidatorTest() override = default;
  26. void SetUp() override
  27. {}
  28. void TearDown() override
  29. {}
  30. };
  31. class SectionPairDocumentValidatorTest_LineBreakTest : public TestWithParam<string>
  32. {
  33. protected:
  34. SectionPairDocumentValidatorTest_LineBreakTest() = default;
  35. ~SectionPairDocumentValidatorTest_LineBreakTest() override = default;
  36. };
  37. class SectionPairDocumentValidatorTest_ValidArgumentTest : public TestWithParam<string>
  38. {
  39. protected:
  40. SectionPairDocumentValidatorTest_ValidArgumentTest() = default;
  41. ~SectionPairDocumentValidatorTest_ValidArgumentTest() override = default;
  42. };
  43. class SectionPairDocumentValidatorTest_InvalidArgumentTest : public TestWithParam<string>
  44. {
  45. protected:
  46. SectionPairDocumentValidatorTest_InvalidArgumentTest() = default;
  47. ~SectionPairDocumentValidatorTest_InvalidArgumentTest() override = default;
  48. };
  49. TEST_F(SectionPairDocumentValidatorTest, getClassName)
  50. {
  51. ASSERT_STREQ("SectionPairDocumentValidator", SectionPairDocumentValidator{"tmp-key"}.getClassName().c_str());
  52. }
  53. TEST_P(SectionPairDocumentValidatorTest_LineBreakTest, isValid)
  54. {
  55. ASSERT_TRUE(SectionPairDocumentValidator{GetParam()}.isValid());
  56. }
  57. TEST_P(SectionPairDocumentValidatorTest_ValidArgumentTest, isValid)
  58. {
  59. ASSERT_TRUE(SectionPairDocumentValidator{GetParam()}.isValid());
  60. }
  61. TEST_P(SectionPairDocumentValidatorTest_InvalidArgumentTest, isValid_not_valid)
  62. {
  63. ASSERT_FALSE(SectionPairDocumentValidator{GetParam()}.isValid());
  64. }
  65. INSTANTIATE_TEST_SUITE_P(LineBreakTest, SectionPairDocumentValidatorTest_LineBreakTest, Values(SectionPairDocumentProvider::createSerializedDocument(NewLine::getWindowsNewLine()), SectionPairDocumentProvider::createSerializedDocument(NewLine::getUnixNewLine())));
  66. INSTANTIATE_TEST_SUITE_P(InvalidArgumentTest, SectionPairDocumentValidatorTest_InvalidArgumentTest, Values("\n[general]\n\ncolors:\nblue\n"));
  67. INSTANTIATE_TEST_SUITE_P(ValidArgumentTest, SectionPairDocumentValidatorTest_ValidArgumentTest, Values(SectionPairDocumentProvider::createSerializedDocumentComputerExample(NewLine::get())));
  68. }