IncompleteJsonExceptionTest.cpp 1.8 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: 2021-05-01
  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::IncompleteJsonException;
  14. using std::string;
  15. using testing::Test;
  16. namespace
  17. {
  18. class IncompleteJsonExceptionTest : public Test
  19. {
  20. public:
  21. IncompleteJsonExceptionTest() = default;
  22. ~IncompleteJsonExceptionTest() override = default;
  23. };
  24. TEST_F(IncompleteJsonExceptionTest, constructor)
  25. {
  26. EXPECT_THROW(
  27. {
  28. try
  29. {
  30. throw IncompleteJsonException{};
  31. }
  32. catch (const IncompleteJsonException &_exception)
  33. {
  34. const string actual = _exception.what();
  35. const string expected = _exception.getName() + " thrown - this JSON string is incomplete.";
  36. EXPECT_STREQ(expected.c_str(), actual.c_str());
  37. throw;
  38. }
  39. },
  40. IncompleteJsonException);
  41. }
  42. TEST_F(IncompleteJsonExceptionTest, constructor_dedicated_message)
  43. {
  44. EXPECT_THROW(
  45. {
  46. try
  47. {
  48. throw IncompleteJsonException{"incomplete: {\"name\":\"}"};
  49. }
  50. catch (const IncompleteJsonException &_exception)
  51. {
  52. const string actual = _exception.what();
  53. const string expected = _exception.getName() + " thrown - incomplete: {\"name\":\"}";
  54. EXPECT_STREQ(expected.c_str(), actual.c_str());
  55. throw;
  56. }
  57. },
  58. IncompleteJsonException);
  59. }
  60. TEST_F(IncompleteJsonExceptionTest, getName)
  61. {
  62. ASSERT_STREQ("IncompleteJsonException", IncompleteJsonException{}.getName().c_str());
  63. }
  64. }