SectionPairFileExtensionValidatorTest.cpp 2.1 KB

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