Kaynağa Gözat

Extended Integer class

- added "getValue" method to Integer class
- extended tests for Integer class
pcmattulat 4 yıl önce
ebeveyn
işleme
7e9c03a5a9

+ 4 - 0
source/boxing/Integer.cpp

@@ -256,3 +256,7 @@ std::string ls_std::Integer::toString()
 {
   return std::to_string(this->value);
 }
+
+int ls_std::Integer::getValue() {
+  return this->value;
+}

+ 4 - 0
source/boxing/Integer.hpp

@@ -105,6 +105,10 @@ namespace ls_std {
       void parse(std::string parseText) override;
       std::string toString() override;
 
+      // additional functionality
+
+      int getValue();
+
     private:
 
       int value {};

+ 8 - 0
test/cases/boxing/IntegerTest.cpp

@@ -366,6 +366,14 @@ namespace {
     ASSERT_STREQ("112", x.toString().c_str());
   }
 
+  // additional functionality
+
+  TEST_F(IntegerTest, getValue)
+  {
+    ls_std::Integer x {3};
+    ASSERT_EQ(3, x.getValue());
+  }
+
   // additional testing
 
   TEST_F(IntegerTest, constApproach)