SectionPairRowListValueArgumentEvaluatorTest.cpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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-23
  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::SectionPairRowListValueArgumentEvaluator;
  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 SectionPairRowListValueArgumentEvaluatorTest : public Test
  25. {
  26. protected:
  27. SectionPairRowListValueArgumentEvaluatorTest() = default;
  28. ~SectionPairRowListValueArgumentEvaluatorTest() override = default;
  29. void SetUp() override
  30. {}
  31. void TearDown() override
  32. {}
  33. };
  34. class SectionPairRowListValueArgumentEvaluatorTest_InvalidArgumentTest : public TestWithParam<string>
  35. {
  36. protected:
  37. SectionPairRowListValueArgumentEvaluatorTest_InvalidArgumentTest() = default;
  38. ~SectionPairRowListValueArgumentEvaluatorTest_InvalidArgumentTest() override = default;
  39. };
  40. TEST_F(SectionPairRowListValueArgumentEvaluatorTest, getClassName)
  41. {
  42. shared_ptr<SectionPairRowListValueArgumentEvaluator> evaluator = make_shared<SectionPairRowListValueArgumentEvaluator>("color=blue");
  43. ASSERT_STREQ("SectionPairRowListValueArgumentEvaluator", evaluator->getClassName().c_str());
  44. }
  45. TEST_P(SectionPairRowListValueArgumentEvaluatorTest_InvalidArgumentTest, evaluate)
  46. {
  47. EXPECT_THROW(
  48. {
  49. try
  50. {
  51. SectionPairRowListValueArgumentEvaluator(GetParam()).evaluate();
  52. }
  53. catch (const IllegalArgumentException &_exception)
  54. {
  55. string actual = _exception.what();
  56. string expected = _exception.getName() + " thrown - \"" + GetParam() + "\" is not a valid section pair list value row!";
  57. ASSERT_STREQ(SectionPairMessageFormatter::getFormattedMessage(expected).c_str(), actual.c_str());
  58. throw;
  59. }
  60. },
  61. IllegalArgumentException);
  62. }
  63. INSTANTIATE_TEST_SUITE_P(InvalidArgumentTest, SectionPairRowListValueArgumentEvaluatorTest_InvalidArgumentTest, Values("colors:", "colors:\n red", "colors:\r\n red"));
  64. }