FileExistenceEvaluatorTest.cpp 1.3 KB

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