SectionPairRowArgumentEvaluatorTest.cpp 2.1 KB

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