Explorar el Código

Add getter method for value member of SectionPairRow class

Patrick-Christopher Mattulat hace 2 años
padre
commit
8b7653ec73

+ 1 - 0
include/ls-std/io/section-pair/SectionPairRow.hpp

@@ -27,6 +27,7 @@ namespace ls::std::io
       ~SectionPairRow() override;
 
       [[nodiscard]] ls::std::io::section_pair_identifier getKey();
+      [[nodiscard]] ::std::shared_ptr<ls::std::io::SectionPairRowValue> getValue();
       [[nodiscard]] bool isList();
       [[nodiscard]] bool isSingleValue();
 

+ 5 - 0
source/ls-std/io/section-pair/SectionPairRow.cpp

@@ -27,6 +27,11 @@ ls::std::io::section_pair_row_value ls::std::io::SectionPairRow::getKey()
   return this->key;
 }
 
+::std::shared_ptr<ls::std::io::SectionPairRowValue> ls::std::io::SectionPairRow::getValue()
+{
+  return this->value;
+}
+
 bool ls::std::io::SectionPairRow::isList()
 {
   return this->value->getType() == ls::std::io::SectionPairRowEnumType::SECTION_PAIR_ROW_LIST_VALUE;

+ 9 - 0
test/cases/io/section-pair/SectionPairRowTest.cpp

@@ -76,6 +76,15 @@ namespace
     ASSERT_STREQ(key.c_str(), row.getKey().c_str());
   }
 
+  TEST_F(SectionPairRowTest, getValue)
+  {
+    SectionPairRow row("hobbies", SectionPairRowEnumType::SECTION_PAIR_ROW_LIST_VALUE);
+    shared_ptr<SectionPairRowValue> value = row.getValue();
+
+    ASSERT_TRUE(value != nullptr);
+    ASSERT_EQ(SectionPairRowEnumType::SECTION_PAIR_ROW_LIST_VALUE, value->getType());
+  }
+
   TEST_F(SectionPairRowTest, isSingleValue)
   {
     ASSERT_TRUE(SectionPairRow("tmp-key", SectionPairRowEnumType::SECTION_PAIR_ROW_SINGLE_VALUE).isSingleValue());