SectionPairRowTest.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-08
  6. * Changed: 2023-02-09
  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 SectionPairRowTest : public ::testing::Test
  18. {
  19. protected:
  20. SectionPairRowTest() = default;
  21. ~SectionPairRowTest() override = default;
  22. void SetUp() override
  23. {}
  24. void TearDown() override
  25. {}
  26. };
  27. TEST_F(SectionPairRowTest, getClassName)
  28. {
  29. ASSERT_STREQ("SectionPairRow", SectionPairRow{"tmp-key"}.getClassName().c_str());
  30. }
  31. TEST_F(SectionPairRowTest, constructor_empty_key)
  32. {
  33. EXPECT_THROW(
  34. {
  35. try
  36. {
  37. SectionPairRow row{""};
  38. }
  39. catch (const IllegalArgumentException &_exception)
  40. {
  41. throw;
  42. }
  43. },
  44. IllegalArgumentException);
  45. }
  46. TEST_F(SectionPairRowTest, constructor_invalid_key)
  47. {
  48. EXPECT_THROW(
  49. {
  50. try
  51. {
  52. SectionPairRow row{"-tmp-key"};
  53. }
  54. catch (const IllegalArgumentException &_exception)
  55. {
  56. throw;
  57. }
  58. },
  59. IllegalArgumentException);
  60. }
  61. TEST_F(SectionPairRowTest, getKey)
  62. {
  63. ::std::string key = "tmp-key";
  64. SectionPairRow row{key};
  65. ASSERT_STREQ(key.c_str(), row.getKey().c_str());
  66. }
  67. TEST_F(SectionPairRowTest, getValue)
  68. {
  69. SectionPairRow row{"tmp-key"};
  70. ASSERT_TRUE(row.getValue().empty());
  71. }
  72. TEST_F(SectionPairRowTest, isKeyValue)
  73. {
  74. ASSERT_FALSE(SectionPairRow{"tmp-key"}.isKeyValue());
  75. }
  76. TEST_F(SectionPairRowTest, isList)
  77. {
  78. ASSERT_FALSE(SectionPairRow{"tmp-key"}.isList());
  79. }
  80. TEST_F(SectionPairRowTest, setValue_key_value)
  81. {
  82. SectionPairRow row{"color"};
  83. row.setValue("blue");
  84. ASSERT_STREQ("blue", row.getValue().c_str());
  85. }
  86. TEST_F(SectionPairRowTest, setValue_key_value_empty_value)
  87. {
  88. SectionPairRow row{"color"};
  89. EXPECT_THROW(
  90. {
  91. try
  92. {
  93. row.setValue("");
  94. }
  95. catch (const IllegalArgumentException &_exception)
  96. {
  97. throw;
  98. }
  99. },
  100. IllegalArgumentException);
  101. }
  102. }