SectionPairFileExtensionValidatorTest.cpp 2.1 KB

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