FileExistenceEvaluatorTest.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. ;
  39. ASSERT_STREQ(expected.c_str(), actual.c_str());
  40. throw;
  41. }
  42. },
  43. FileNotFoundException);
  44. }
  45. INSTANTIATE_TEST_SUITE_P(FileExistenceEvaluatorTest, FileExistenceEvaluatorTest, Values("var/log/log.txt", ".test"));
  46. }