FileExistenceEvaluatorTest.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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-core.hpp>
  11. #include <ls-std/ls-std-io.hpp>
  12. #include <string>
  13. using ls::std::core::FileNotFoundException;
  14. using ls::std::io::FileExistenceEvaluator;
  15. using std::string;
  16. using testing::TestWithParam;
  17. using testing::Values;
  18. namespace
  19. {
  20. class FileExistenceEvaluatorTest : public TestWithParam<string>
  21. {
  22. public:
  23. FileExistenceEvaluatorTest() = default;
  24. ~FileExistenceEvaluatorTest() override = default;
  25. };
  26. TEST_P(FileExistenceEvaluatorTest, evaluate)
  27. {
  28. EXPECT_THROW(
  29. {
  30. try
  31. {
  32. FileExistenceEvaluator{GetParam()}.evaluate();
  33. }
  34. catch (const FileNotFoundException &_exception)
  35. {
  36. string actual = _exception.what();
  37. string expected = _exception.getName() + " thrown - \"" + GetParam() + "\" does not exist!";
  38. ASSERT_STREQ(expected.c_str(), actual.c_str());
  39. throw;
  40. }
  41. },
  42. FileNotFoundException);
  43. }
  44. INSTANTIATE_TEST_SUITE_P(FileExistenceEvaluatorTest, FileExistenceEvaluatorTest, Values("var/log/log.txt", ".test"));
  45. }