SectionPairSectionArgumentEvaluatorTest.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-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. namespace
  17. {
  18. class SectionPairSectionArgumentEvaluatorTest : public ::testing::Test
  19. {
  20. protected:
  21. SectionPairSectionArgumentEvaluatorTest() = default;
  22. ~SectionPairSectionArgumentEvaluatorTest() override = default;
  23. void SetUp() override
  24. {}
  25. void TearDown() override
  26. {}
  27. };
  28. class SectionPairSectionArgumentEvaluatorTest_InvalidArgumentTest : public ::testing::TestWithParam<string>
  29. {
  30. protected:
  31. SectionPairSectionArgumentEvaluatorTest_InvalidArgumentTest() = default;
  32. ~SectionPairSectionArgumentEvaluatorTest_InvalidArgumentTest() override = default;
  33. };
  34. TEST_F(SectionPairSectionArgumentEvaluatorTest, getClassName)
  35. {
  36. shared_ptr<SectionPairSectionArgumentEvaluator> evaluator = make_shared<SectionPairSectionArgumentEvaluator>("=33");
  37. ASSERT_STREQ("SectionPairSectionArgumentEvaluator", evaluator->getClassName().c_str());
  38. }
  39. TEST_P(SectionPairSectionArgumentEvaluatorTest_InvalidArgumentTest, evaluate)
  40. {
  41. EXPECT_THROW(
  42. {
  43. try
  44. {
  45. SectionPairSectionArgumentEvaluator(GetParam()).evaluate();
  46. }
  47. catch (const IllegalArgumentException &_exception)
  48. {
  49. ::std::string actual = _exception.what();
  50. ::std::string expected = _exception.getName() + " thrown - \"" + GetParam() + "\" is not a valid section!";
  51. ASSERT_STREQ(SectionPairMessageFormatter::getFormattedMessage(expected).c_str(), actual.c_str());
  52. throw;
  53. }
  54. },
  55. IllegalArgumentException);
  56. }
  57. INSTANTIATE_TEST_SUITE_P(InvalidArgumentTest, SectionPairSectionArgumentEvaluatorTest_InvalidArgumentTest, ::testing::Values("\n[general]\n\n", "\n[section]\n\ncolors:"));
  58. }