SectionPairValueArgumentEvaluatorTest.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-10
  6. * Changed: 2023-06-06
  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. public:
  26. SectionPairValueArgumentEvaluatorTest() = default;
  27. ~SectionPairValueArgumentEvaluatorTest() override = default;
  28. };
  29. class SectionPairValueArgumentEvaluatorTest_InvalidArgumentTest : public TestWithParam<string>
  30. {
  31. public:
  32. SectionPairValueArgumentEvaluatorTest_InvalidArgumentTest() = default;
  33. ~SectionPairValueArgumentEvaluatorTest_InvalidArgumentTest() override = default;
  34. };
  35. TEST_F(SectionPairValueArgumentEvaluatorTest, getClassName)
  36. {
  37. auto evaluator = make_shared<SectionPairValueArgumentEvaluator>("=33");
  38. ASSERT_STREQ("SectionPairValueArgumentEvaluator", evaluator->getClassName().c_str());
  39. }
  40. TEST_P(SectionPairValueArgumentEvaluatorTest_InvalidArgumentTest, evaluate)
  41. {
  42. EXPECT_THROW(
  43. {
  44. try
  45. {
  46. SectionPairValueArgumentEvaluator(GetParam()).evaluate();
  47. }
  48. catch (const IllegalArgumentException &_exception)
  49. {
  50. string actual = _exception.what();
  51. string expected = _exception.getName() + " thrown - \"" + GetParam() + "\" is not a valid value!";
  52. ASSERT_STREQ(expected.c_str(), actual.c_str());
  53. throw;
  54. }
  55. },
  56. IllegalArgumentException);
  57. }
  58. INSTANTIATE_TEST_SUITE_P(InvalidArgumentTest, SectionPairValueArgumentEvaluatorTest_InvalidArgumentTest, Values("=33"));
  59. }