SectionPairRowArgumentEvaluatorTest.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-20
  6. * Changed: 2023-02-22
  7. *
  8. * */
  9. #include <gtest/gtest.h>
  10. #include <ls-std/ls-std-core.hpp>
  11. #include <ls-std/ls-std-io.hpp>
  12. #include <string>
  13. using namespace ls::std::core;
  14. using namespace ls::std::io;
  15. using namespace ::std;
  16. using namespace ::testing;
  17. namespace
  18. {
  19. class SectionPairRowArgumentEvaluatorTest : public Test
  20. {
  21. protected:
  22. SectionPairRowArgumentEvaluatorTest() = default;
  23. ~SectionPairRowArgumentEvaluatorTest() override = default;
  24. void SetUp() override
  25. {}
  26. void TearDown() override
  27. {}
  28. };
  29. class SectionPairRowArgumentEvaluatorTest_InvalidArgumentTest : public TestWithParam<string>
  30. {
  31. protected:
  32. SectionPairRowArgumentEvaluatorTest_InvalidArgumentTest() = default;
  33. ~SectionPairRowArgumentEvaluatorTest_InvalidArgumentTest() override = default;
  34. };
  35. TEST_F(SectionPairRowArgumentEvaluatorTest, getClassName)
  36. {
  37. shared_ptr<SectionPairRowArgumentEvaluator> evaluator = make_shared<SectionPairRowArgumentEvaluator>("empty");
  38. ASSERT_STREQ("SectionPairRowArgumentEvaluator", evaluator->getClassName().c_str());
  39. }
  40. TEST_P(SectionPairRowArgumentEvaluatorTest_InvalidArgumentTest, evaluate)
  41. {
  42. EXPECT_THROW(
  43. {
  44. try
  45. {
  46. SectionPairRowArgumentEvaluator(GetParam()).evaluate();
  47. }
  48. catch (const IllegalArgumentException &_exception)
  49. {
  50. string actual = _exception.what();
  51. string expected = _exception.getName() + " thrown - \"" + GetParam() + "\" is not a valid section pair row!";
  52. ASSERT_STREQ(SectionPairMessageFormatter::getFormattedMessage(expected).c_str(), actual.c_str());
  53. throw;
  54. }
  55. },
  56. IllegalArgumentException);
  57. }
  58. INSTANTIATE_TEST_SUITE_P(InvalidArgumentTest, SectionPairRowArgumentEvaluatorTest_InvalidArgumentTest, Values("heroes:\n phil", "shapes:\r\n triangle\r\nsquare"));
  59. }