NotImplementedExceptionTest.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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-03-27
  7. * Changed: 2026-06-23
  8. *
  9. * */
  10. #include <gtest/gtest.h>
  11. #include <ls-std/ls-std-core.hpp>
  12. #include <string>
  13. using ls::standard::core::NotImplementedException;
  14. using std::string;
  15. using testing::Test;
  16. namespace
  17. {
  18. class NotImplementedExceptionTest : public Test
  19. {
  20. public:
  21. NotImplementedExceptionTest() = default;
  22. ~NotImplementedExceptionTest() override = default;
  23. };
  24. TEST_F(NotImplementedExceptionTest, constructor)
  25. {
  26. EXPECT_THROW(
  27. {
  28. try
  29. {
  30. throw NotImplementedException{};
  31. }
  32. catch (const NotImplementedException &_exception)
  33. {
  34. const string actual = _exception.what();
  35. const string expected = _exception.getName() + " thrown - method is not implemented and should not be used!";
  36. EXPECT_STREQ(expected.c_str(), actual.c_str());
  37. throw;
  38. }
  39. },
  40. NotImplementedException);
  41. }
  42. TEST_F(NotImplementedExceptionTest, constructor_dedicated_message)
  43. {
  44. EXPECT_THROW(
  45. {
  46. try
  47. {
  48. throw NotImplementedException{R"lit(method "marshal" is not implemented!)lit"};
  49. }
  50. catch (const NotImplementedException &_exception)
  51. {
  52. const string actual = _exception.what();
  53. const string expected = _exception.getName() + R"lit( thrown - method "marshal" is not implemented!)lit";
  54. EXPECT_STREQ(expected.c_str(), actual.c_str());
  55. throw;
  56. }
  57. },
  58. NotImplementedException);
  59. }
  60. TEST_F(NotImplementedExceptionTest, getName)
  61. {
  62. ASSERT_STREQ("NotImplementedException", NotImplementedException{}.getName().c_str());
  63. }
  64. }