SectionPairSectionArgumentEvaluatorTest.cpp 2.2 KB

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