EmptyStringArgumentEvaluatorTest.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-08
  6. * Changed: 2024-05-31
  7. *
  8. * */
  9. #include <gtest/gtest.h>
  10. #include <ls-std/ls-std-core.hpp>
  11. #include <string>
  12. using ls::std::core::EmptyStringArgumentEvaluator;
  13. using ls::std::core::IllegalArgumentException;
  14. using std::string;
  15. using testing::Test;
  16. namespace
  17. {
  18. class EmptyStringArgumentEvaluatorTest : public Test
  19. {
  20. public:
  21. EmptyStringArgumentEvaluatorTest() = default;
  22. ~EmptyStringArgumentEvaluatorTest() override = default;
  23. };
  24. TEST_F(EmptyStringArgumentEvaluatorTest, evaluate)
  25. {
  26. EXPECT_THROW(
  27. {
  28. try
  29. {
  30. EmptyStringArgumentEvaluator{""}.evaluate();
  31. }
  32. catch (const IllegalArgumentException &_exception)
  33. {
  34. const string actual = _exception.what();
  35. const string expected = _exception.getName() + " thrown - passed argument is empty!";
  36. ASSERT_STREQ(expected.c_str(), actual.c_str());
  37. throw;
  38. }
  39. },
  40. IllegalArgumentException);
  41. }
  42. TEST_F(EmptyStringArgumentEvaluatorTest, evaluate_dedicated_message)
  43. {
  44. EXPECT_THROW(
  45. {
  46. try
  47. {
  48. EmptyStringArgumentEvaluator("", "this id is empty!").evaluate();
  49. }
  50. catch (const IllegalArgumentException &_exception)
  51. {
  52. const string actual = _exception.what();
  53. const string expected = _exception.getName() + " thrown - this id is empty!";
  54. ASSERT_STREQ(expected.c_str(), actual.c_str());
  55. throw;
  56. }
  57. },
  58. IllegalArgumentException);
  59. }
  60. }