FileExistenceEvaluatorTest.cpp 1.3 KB

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