FileExistenceEvaluatorTest.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Co-Author: Claude Sonnet 4.6 (LLM)
  4. * Company: Lynar Studios
  5. * E-Mail: webmaster@lynarstudios.com
  6. * Created: 2023-02-21
  7. * Changed: 2026-06-23
  8. *
  9. * */
  10. #include <gtest/gtest.h>
  11. #include <ls-std/ls-std-core.hpp>
  12. #include <ls-std/ls-std-io.hpp>
  13. #include <string>
  14. using ls::standard::core::FileNotFoundException;
  15. using ls::standard::io::FileExistenceEvaluator;
  16. using std::string;
  17. using testing::TestWithParam;
  18. using testing::Values;
  19. namespace
  20. {
  21. class FileExistenceEvaluatorTest : public TestWithParam<string>
  22. {
  23. public:
  24. FileExistenceEvaluatorTest() = default;
  25. ~FileExistenceEvaluatorTest() override = default;
  26. };
  27. TEST_P(FileExistenceEvaluatorTest, evaluate)
  28. {
  29. EXPECT_THROW(
  30. {
  31. try
  32. {
  33. FileExistenceEvaluator{GetParam()}.evaluate();
  34. }
  35. catch (const FileNotFoundException &_exception)
  36. {
  37. const string actual = _exception.what();
  38. const string expected = _exception.getName() + " thrown - \"" + GetParam() + "\" does not exist!";
  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. }