SectionPairFileExtensionValidatorTest.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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/ls-std-io.hpp>
  11. #include <string>
  12. using ls::std::io::SectionPairFileExtensionValidator;
  13. using std::string;
  14. using testing::Test;
  15. using testing::TestWithParam;
  16. using testing::Values;
  17. namespace
  18. {
  19. class SectionPairFileExtensionValidatorTest : public Test
  20. {
  21. public:
  22. SectionPairFileExtensionValidatorTest() = default;
  23. ~SectionPairFileExtensionValidatorTest() override = default;
  24. };
  25. class SectionPairFileExtensionValidatorTest_ValidExtensionTest : public TestWithParam<string>
  26. {
  27. public:
  28. SectionPairFileExtensionValidatorTest_ValidExtensionTest() = default;
  29. ~SectionPairFileExtensionValidatorTest_ValidExtensionTest() override = default;
  30. };
  31. class SectionPairFileExtensionValidatorTest_NotValidExtensionTest : public TestWithParam<string>
  32. {
  33. public:
  34. SectionPairFileExtensionValidatorTest_NotValidExtensionTest() = default;
  35. ~SectionPairFileExtensionValidatorTest_NotValidExtensionTest() override = default;
  36. };
  37. TEST_F(SectionPairFileExtensionValidatorTest, getClassName)
  38. {
  39. ASSERT_STREQ("SectionPairFileExtensionValidator", SectionPairFileExtensionValidator{"tmp.txt"}.getClassName().c_str());
  40. }
  41. TEST_P(SectionPairFileExtensionValidatorTest_ValidExtensionTest, isValid)
  42. {
  43. ASSERT_TRUE(SectionPairFileExtensionValidator{GetParam()}.isValid());
  44. }
  45. TEST_P(SectionPairFileExtensionValidatorTest_NotValidExtensionTest, isValid)
  46. {
  47. ASSERT_FALSE(SectionPairFileExtensionValidator{GetParam()}.isValid());
  48. }
  49. INSTANTIATE_TEST_SUITE_P(ValidExtensionTest, SectionPairFileExtensionValidatorTest_ValidExtensionTest, Values("server-settings.txt", "settings.sp", "/var/log/settings.txt"));
  50. INSTANTIATE_TEST_SUITE_P(NotValidExtensionTest, SectionPairFileExtensionValidatorTest_NotValidExtensionTest, Values("server-settings.json", "settings.html", "/var/log/settings"));
  51. }