SectionPairIdentifierArgumentEvaluatorTest.cpp 2.1 KB

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