IndexOutOfBoundsEvaluatorTest.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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-02-10
  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::IndexOutOfBoundsEvaluator;
  14. using ls::standard::core::IndexOutOfBoundsException;
  15. using std::string;
  16. using testing::Test;
  17. namespace
  18. {
  19. class IndexOutOfBoundsEvaluatorTest : public Test
  20. {
  21. public:
  22. IndexOutOfBoundsEvaluatorTest() = default;
  23. ~IndexOutOfBoundsEvaluatorTest() override = default;
  24. };
  25. TEST_F(IndexOutOfBoundsEvaluatorTest, evaluate)
  26. {
  27. EXPECT_THROW(
  28. {
  29. try
  30. {
  31. IndexOutOfBoundsEvaluator(3, 2).evaluate();
  32. }
  33. catch (const IndexOutOfBoundsException &_exception)
  34. {
  35. string actual = _exception.what();
  36. string expected = _exception.getName() + " thrown - provided index is out of bounds!";
  37. ASSERT_STREQ(expected.c_str(), actual.c_str());
  38. throw;
  39. }
  40. },
  41. IndexOutOfBoundsException);
  42. }
  43. TEST_F(IndexOutOfBoundsEvaluatorTest, evaluate_dedicated_message)
  44. {
  45. EXPECT_THROW(
  46. {
  47. try
  48. {
  49. IndexOutOfBoundsEvaluator(3, 2, "index 3 is not in range of the containers size, which is 2!").evaluate();
  50. }
  51. catch (const IndexOutOfBoundsException &_exception)
  52. {
  53. const string actual = _exception.what();
  54. const string expected = _exception.getName() + " thrown - index 3 is not in range of the containers size, which is 2!";
  55. ASSERT_STREQ(expected.c_str(), actual.c_str());
  56. throw;
  57. }
  58. },
  59. IndexOutOfBoundsException);
  60. }
  61. }