SectionPairFileExtensionValidatorTest.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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/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. protected:
  22. SectionPairFileExtensionValidatorTest() = default;
  23. ~SectionPairFileExtensionValidatorTest() override = default;
  24. void SetUp() override
  25. {}
  26. void TearDown() override
  27. {}
  28. };
  29. class SectionPairFileExtensionValidatorTest_ValidExtensionTest : public TestWithParam<string>
  30. {
  31. protected:
  32. SectionPairFileExtensionValidatorTest_ValidExtensionTest() = default;
  33. ~SectionPairFileExtensionValidatorTest_ValidExtensionTest() override = default;
  34. };
  35. class SectionPairFileExtensionValidatorTest_NotValidExtensionTest : public TestWithParam<string>
  36. {
  37. protected:
  38. SectionPairFileExtensionValidatorTest_NotValidExtensionTest() = default;
  39. ~SectionPairFileExtensionValidatorTest_NotValidExtensionTest() override = default;
  40. };
  41. TEST_F(SectionPairFileExtensionValidatorTest, getClassName)
  42. {
  43. ASSERT_STREQ("SectionPairFileExtensionValidator", SectionPairFileExtensionValidator{"tmp.txt"}.getClassName().c_str());
  44. }
  45. TEST_P(SectionPairFileExtensionValidatorTest_ValidExtensionTest, isValid)
  46. {
  47. ASSERT_TRUE(SectionPairFileExtensionValidator{GetParam()}.isValid());
  48. }
  49. TEST_P(SectionPairFileExtensionValidatorTest_NotValidExtensionTest, isValid)
  50. {
  51. ASSERT_FALSE(SectionPairFileExtensionValidator{GetParam()}.isValid());
  52. }
  53. INSTANTIATE_TEST_SUITE_P(ValidExtensionTest, SectionPairFileExtensionValidatorTest_ValidExtensionTest, Values("server-settings.txt", "settings.sp", "/var/log/settings.txt"));
  54. INSTANTIATE_TEST_SUITE_P(NotValidExtensionTest, SectionPairFileExtensionValidatorTest_NotValidExtensionTest, Values("server-settings.json", "settings.html", "/var/log/settings"));
  55. }