SectionPairValueArgumentEvaluatorTest.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-10
  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::SectionPairValueArgumentEvaluator;
  15. using std::make_shared;
  16. using std::shared_ptr;
  17. using std::string;
  18. using testing::Test;
  19. using testing::TestWithParam;
  20. using testing::Values;
  21. namespace
  22. {
  23. class SectionPairValueArgumentEvaluatorTest : public Test
  24. {
  25. protected:
  26. SectionPairValueArgumentEvaluatorTest() = default;
  27. ~SectionPairValueArgumentEvaluatorTest() override = default;
  28. void SetUp() override
  29. {}
  30. void TearDown() override
  31. {}
  32. };
  33. class SectionPairValueArgumentEvaluatorTest_InvalidArgumentTest : public TestWithParam<string>
  34. {
  35. protected:
  36. SectionPairValueArgumentEvaluatorTest_InvalidArgumentTest() = default;
  37. ~SectionPairValueArgumentEvaluatorTest_InvalidArgumentTest() override = default;
  38. };
  39. TEST_F(SectionPairValueArgumentEvaluatorTest, getClassName)
  40. {
  41. shared_ptr<SectionPairValueArgumentEvaluator> evaluator = make_shared<SectionPairValueArgumentEvaluator>("=33");
  42. ASSERT_STREQ("SectionPairValueArgumentEvaluator", evaluator->getClassName().c_str());
  43. }
  44. TEST_P(SectionPairValueArgumentEvaluatorTest_InvalidArgumentTest, evaluate)
  45. {
  46. EXPECT_THROW(
  47. {
  48. try
  49. {
  50. SectionPairValueArgumentEvaluator(GetParam()).evaluate();
  51. }
  52. catch (const IllegalArgumentException &_exception)
  53. {
  54. string actual = _exception.what();
  55. string expected = _exception.getName() + " thrown - \"" + GetParam() + "\" is not a valid value!";
  56. ASSERT_STREQ(expected.c_str(), actual.c_str());
  57. throw;
  58. }
  59. },
  60. IllegalArgumentException);
  61. }
  62. INSTANTIATE_TEST_SUITE_P(InvalidArgumentTest, SectionPairValueArgumentEvaluatorTest_InvalidArgumentTest, Values("=33", "\\empty"));
  63. }