Browse Source

Extended Boolean class

- added "getValue" method to Boolean class
- extended tests for Boolean class
pcmattulat 4 years ago
parent
commit
777270eb5c
3 changed files with 13 additions and 2 deletions
  1. 5 1
      source/boxing/Boolean.cpp
  2. 1 0
      source/boxing/Boolean.hpp
  3. 7 1
      test/cases/boxing/BooleanTest.cpp

+ 5 - 1
source/boxing/Boolean.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-08-09
- * Changed:         2020-08-09
+ * Changed:         2020-08-14
  *
  * */
 
@@ -87,6 +87,10 @@ std::string ls_std::Boolean::toString()
   return this->_toString();
 }
 
+bool ls_std::Boolean::getValue() {
+  return this->value;
+}
+
 bool ls_std::Boolean::XOR(const Boolean &_leftExpression, const Boolean &_rightExpression) {
   return (_leftExpression && !_rightExpression) || (!_leftExpression && _rightExpression);
 }

+ 1 - 0
source/boxing/Boolean.hpp

@@ -58,6 +58,7 @@ namespace ls_std {
 
       // additional functionality
 
+      bool getValue();
       static bool XOR(const Boolean& _leftExpression, const Boolean& _rightExpression);
       static bool XOR(const Boolean& _leftExpression, bool _rightExpression);
       static bool XOR(bool _leftExpression, const Boolean& _rightExpression);

+ 7 - 1
test/cases/boxing/BooleanTest.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-08-09
- * Changed:         2020-08-09
+ * Changed:         2020-08-14
  *
  * */
 
@@ -145,6 +145,12 @@ namespace {
 
   // additional functionality
 
+  TEST_F(BooleanTest, getValue)
+  {
+    ls_std::Boolean x {2 < 3};
+    ASSERT_TRUE(x.getValue());
+  }
+
   TEST_F(BooleanTest, XOR)
   {
     ls_std::Boolean x {2 < 3};