Browse Source

Extended Integer class

- added "getValue" method to Integer class
- extended tests for Integer class
pcmattulat 4 years ago
parent
commit
7e9c03a5a9
3 changed files with 16 additions and 0 deletions
  1. 4 0
      source/boxing/Integer.cpp
  2. 4 0
      source/boxing/Integer.hpp
  3. 8 0
      test/cases/boxing/IntegerTest.cpp

+ 4 - 0
source/boxing/Integer.cpp

@@ -256,3 +256,7 @@ std::string ls_std::Integer::toString()
 {
 {
   return std::to_string(this->value);
   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;
       void parse(std::string parseText) override;
       std::string toString() override;
       std::string toString() override;
 
 
+      // additional functionality
+
+      int getValue();
+
     private:
     private:
 
 
       int value {};
       int value {};

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

@@ -366,6 +366,14 @@ namespace {
     ASSERT_STREQ("112", x.toString().c_str());
     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
   // additional testing
 
 
   TEST_F(IntegerTest, constApproach)
   TEST_F(IntegerTest, constApproach)