SectionPairIdentifierArgumentEvaluatorTest.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-09
  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::SectionPairIdentifierArgumentEvaluator;
  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 SectionPairIdentifierArgumentEvaluatorTest : public Test
  24. {
  25. protected:
  26. SectionPairIdentifierArgumentEvaluatorTest() = default;
  27. ~SectionPairIdentifierArgumentEvaluatorTest() override = default;
  28. void SetUp() override
  29. {}
  30. void TearDown() override
  31. {}
  32. };
  33. class SectionPairIdentifierArgumentEvaluatorTest_InvalidArgumentTest : public TestWithParam<string>
  34. {
  35. protected:
  36. SectionPairIdentifierArgumentEvaluatorTest_InvalidArgumentTest() = default;
  37. ~SectionPairIdentifierArgumentEvaluatorTest_InvalidArgumentTest() override = default;
  38. };
  39. TEST_F(SectionPairIdentifierArgumentEvaluatorTest, getClassName)
  40. {
  41. shared_ptr<SectionPairIdentifierArgumentEvaluator> evaluator = make_shared<SectionPairIdentifierArgumentEvaluator>("_id");
  42. ASSERT_STREQ("SectionPairIdentifierArgumentEvaluator", evaluator->getClassName().c_str());
  43. }
  44. TEST_P(SectionPairIdentifierArgumentEvaluatorTest_InvalidArgumentTest, evaluate)
  45. {
  46. EXPECT_THROW(
  47. {
  48. try
  49. {
  50. SectionPairIdentifierArgumentEvaluator(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 identifier!";
  56. ASSERT_STREQ(expected.c_str(), actual.c_str());
  57. throw;
  58. }
  59. },
  60. IllegalArgumentException);
  61. }
  62. INSTANTIATE_TEST_SUITE_P(InvalidArgumentTest, SectionPairIdentifierArgumentEvaluatorTest_InvalidArgumentTest, Values("_color", "Color", "another_color"));
  63. }