SectionPairRowSingleValueTest.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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-11
  7. *
  8. * */
  9. #include <gtest/gtest.h>
  10. #include <ls-std/ls-std-core.hpp>
  11. #include <ls-std/ls-std-io.hpp>
  12. using namespace ls::std::core;
  13. using namespace ls::std::io;
  14. using namespace ::std;
  15. namespace
  16. {
  17. class SectionPairRowSingleValueTest : public ::testing::Test
  18. {
  19. protected:
  20. SectionPairRowSingleValueTest() = default;
  21. ~SectionPairRowSingleValueTest() override = default;
  22. void SetUp() override
  23. {}
  24. void TearDown() override
  25. {}
  26. };
  27. TEST_F(SectionPairRowSingleValueTest, getClassName)
  28. {
  29. ASSERT_STREQ("SectionPairRowSingleValue", SectionPairRowSingleValue{"blue"}.getClassName().c_str());
  30. }
  31. TEST_F(SectionPairRowSingleValueTest, constructor_empty_value)
  32. {
  33. EXPECT_THROW(
  34. {
  35. try
  36. {
  37. SectionPairRowSingleValue value{""};
  38. }
  39. catch (const IllegalArgumentException &_exception)
  40. {
  41. throw;
  42. }
  43. },
  44. IllegalArgumentException);
  45. }
  46. TEST_F(SectionPairRowSingleValueTest, constructor_invalid_value)
  47. {
  48. EXPECT_THROW(
  49. {
  50. try
  51. {
  52. SectionPairRowSingleValue value{"=33"};
  53. }
  54. catch (const IllegalArgumentException &_exception)
  55. {
  56. throw;
  57. }
  58. },
  59. IllegalArgumentException);
  60. }
  61. TEST_F(SectionPairRowSingleValueTest, get)
  62. {
  63. SectionPairRowSingleValue value{"blue"};
  64. ASSERT_STREQ("blue", value.get().c_str());
  65. }
  66. TEST_F(SectionPairRowSingleValueTest, getType)
  67. {
  68. SectionPairRowSingleValue value{"blue"};
  69. ASSERT_EQ(ls::std::io::SECTION_PAIR_ROW_SINGLE_VALUE, value.getType());
  70. }
  71. TEST_F(SectionPairRowSingleValueTest, set_empty_value)
  72. {
  73. SectionPairRowSingleValue value{"empty"};
  74. EXPECT_THROW(
  75. {
  76. try
  77. {
  78. value.set("");
  79. }
  80. catch (const IllegalArgumentException &_exception)
  81. {
  82. throw;
  83. }
  84. },
  85. IllegalArgumentException);
  86. }
  87. TEST_F(SectionPairRowSingleValueTest, set_invalid_value)
  88. {
  89. SectionPairRowSingleValue value{"empty"};
  90. EXPECT_THROW(
  91. {
  92. try
  93. {
  94. value.set("=33");
  95. }
  96. catch (const IllegalArgumentException &_exception)
  97. {
  98. throw;
  99. }
  100. },
  101. IllegalArgumentException);
  102. }
  103. }