EmptyStringArgumentEvaluatorTest.cpp 1.6 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: 2023-02-08
  7. *
  8. * */
  9. #include <gtest/gtest.h>
  10. #include <ls-std/ls-std-core.hpp>
  11. #include <string>
  12. using namespace ls::std::core;
  13. using namespace ::std;
  14. namespace
  15. {
  16. class EmptyStringArgumentEvaluatorTest : public ::testing::Test
  17. {
  18. protected:
  19. EmptyStringArgumentEvaluatorTest() = default;
  20. ~EmptyStringArgumentEvaluatorTest() override = default;
  21. void SetUp() override
  22. {}
  23. void TearDown() override
  24. {}
  25. };
  26. TEST_F(EmptyStringArgumentEvaluatorTest, evaluate)
  27. {
  28. EXPECT_THROW(
  29. {
  30. try
  31. {
  32. EmptyStringArgumentEvaluator{""}.evaluate();
  33. }
  34. catch (const IllegalArgumentException &_exception)
  35. {
  36. string message = _exception.what();
  37. ASSERT_STREQ("IllegalArgumentException thrown - passed argument is empty!", message.c_str());
  38. throw;
  39. }
  40. },
  41. IllegalArgumentException);
  42. }
  43. TEST_F(EmptyStringArgumentEvaluatorTest, evaluate_dedicated_message)
  44. {
  45. EXPECT_THROW(
  46. {
  47. try
  48. {
  49. EmptyStringArgumentEvaluator("", "this id is empty!").evaluate();
  50. }
  51. catch (const IllegalArgumentException &_exception)
  52. {
  53. string message = _exception.what();
  54. ASSERT_STREQ("IllegalArgumentException thrown - this id is empty!", message.c_str());
  55. throw;
  56. }
  57. },
  58. IllegalArgumentException);
  59. }
  60. }