EmptyStringArgumentEvaluatorTest.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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-22
  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. protected:
  21. EmptyStringArgumentEvaluatorTest() = default;
  22. ~EmptyStringArgumentEvaluatorTest() override = default;
  23. void SetUp() override
  24. {}
  25. void TearDown() override
  26. {}
  27. };
  28. TEST_F(EmptyStringArgumentEvaluatorTest, evaluate)
  29. {
  30. EXPECT_THROW(
  31. {
  32. try
  33. {
  34. EmptyStringArgumentEvaluator{""}.evaluate();
  35. }
  36. catch (const IllegalArgumentException &_exception)
  37. {
  38. string actual = _exception.what();
  39. string expected = _exception.getName() + " thrown - passed argument is empty!";
  40. ASSERT_STREQ(expected.c_str(), actual.c_str());
  41. throw;
  42. }
  43. },
  44. IllegalArgumentException);
  45. }
  46. TEST_F(EmptyStringArgumentEvaluatorTest, evaluate_dedicated_message)
  47. {
  48. EXPECT_THROW(
  49. {
  50. try
  51. {
  52. EmptyStringArgumentEvaluator("", "this id is empty!").evaluate();
  53. }
  54. catch (const IllegalArgumentException &_exception)
  55. {
  56. string actual = _exception.what();
  57. string expected = _exception.getName() + " thrown - this id is empty!";
  58. ASSERT_STREQ(expected.c_str(), actual.c_str());
  59. throw;
  60. }
  61. },
  62. IllegalArgumentException);
  63. }
  64. }