FileNotFoundExceptionTest.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2021-05-01
  6. * Changed: 2023-02-07
  7. *
  8. * */
  9. #include <gtest/gtest.h>
  10. #include <ls-std/ls-std-core.hpp>
  11. using namespace ls::std::core;
  12. namespace
  13. {
  14. class FileNotFoundExceptionTest : public ::testing::Test
  15. {
  16. protected:
  17. FileNotFoundExceptionTest() = default;
  18. ~FileNotFoundExceptionTest() override = default;
  19. void SetUp() override
  20. {}
  21. void TearDown() override
  22. {}
  23. };
  24. TEST_F(FileNotFoundExceptionTest, constructor)
  25. {
  26. EXPECT_THROW(
  27. {
  28. try
  29. {
  30. throw FileNotFoundException{};
  31. }
  32. catch (const FileNotFoundException &_exception)
  33. {
  34. EXPECT_STREQ("FileNotFoundException thrown - file not found!", _exception.what());
  35. throw;
  36. }
  37. },
  38. FileNotFoundException);
  39. }
  40. TEST_F(FileNotFoundExceptionTest, constructor_dedicated_message)
  41. {
  42. EXPECT_THROW(
  43. {
  44. try
  45. {
  46. throw FileNotFoundException{R"("settings.txt" not found!)"};
  47. }
  48. catch (const FileNotFoundException &_exception)
  49. {
  50. EXPECT_STREQ(R"(FileNotFoundException thrown - "settings.txt" not found!)", _exception.what());
  51. throw;
  52. }
  53. },
  54. FileNotFoundException);
  55. }
  56. }