SectionPairDocumentValidatorTest.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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-21
  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. namespace
  19. {
  20. class SectionPairDocumentValidatorTest : public ::testing::Test
  21. {
  22. protected:
  23. SectionPairDocumentValidatorTest() = default;
  24. ~SectionPairDocumentValidatorTest() override = default;
  25. void SetUp() override
  26. {}
  27. void TearDown() override
  28. {}
  29. };
  30. class SectionPairDocumentValidatorTest_LineBreakTest : public ::testing::TestWithParam<string>
  31. {
  32. protected:
  33. SectionPairDocumentValidatorTest_LineBreakTest() = default;
  34. ~SectionPairDocumentValidatorTest_LineBreakTest() override = default;
  35. };
  36. class SectionPairDocumentValidatorTest_ValidArgumentTest : public ::testing::TestWithParam<string>
  37. {
  38. protected:
  39. SectionPairDocumentValidatorTest_ValidArgumentTest() = default;
  40. ~SectionPairDocumentValidatorTest_ValidArgumentTest() override = default;
  41. };
  42. class SectionPairDocumentValidatorTest_InvalidArgumentTest : public ::testing::TestWithParam<string>
  43. {
  44. protected:
  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, ::testing::Values(SectionPairDocumentProvider::createSerializedDocument(NewLine::getWindowsNewLine()), SectionPairDocumentProvider::createSerializedDocument(NewLine::getUnixNewLine())));
  65. INSTANTIATE_TEST_SUITE_P(InvalidArgumentTest, SectionPairDocumentValidatorTest_InvalidArgumentTest, ::testing::Values("\n[general]\n\ncolors:\nblue\n"));
  66. INSTANTIATE_TEST_SUITE_P(ValidArgumentTest, SectionPairDocumentValidatorTest_ValidArgumentTest, ::testing::Values(SectionPairDocumentProvider::createSerializedDocumentComputerExample(NewLine::get())));
  67. }