Browse Source

Fix clang-tidy warnings inside Long class

Patrick-Christopher Mattulat 1 year ago
parent
commit
5859851b34
3 changed files with 34 additions and 43 deletions
  1. 1 5
      include/ls-std/boxing/Long.hpp
  2. 18 23
      source/ls-std/boxing/Long.cpp
  3. 15 15
      test/cases/boxing/LongTest.cpp

+ 1 - 5
include/ls-std/boxing/Long.hpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-08-17
- * Changed:         2023-02-08
+ * Changed:         2023-02-22
  *
  * */
 
@@ -26,10 +26,6 @@ namespace ls::std::boxing
       Long();
       ~Long() override;
 
-      // conversion operator
-
-      operator ls::std::core::type::long_type() const;
-
       // assignment operators
 
       ls::std::boxing::Long &operator=(ls::std::core::type::long_type _value);

+ 18 - 23
source/ls-std/boxing/Long.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-08-17
- * Changed:         2023-02-07
+ * Changed:         2023-02-22
  *
  * */
 
@@ -18,11 +18,6 @@ ls::std::boxing::Long::Long() : ls::std::core::Class("Long")
 
 ls::std::boxing::Long::~Long() = default;
 
-ls::std::boxing::Long::operator ls::std::core::type::long_type() const
-{
-  return this->value;
-}
-
 ls::std::boxing::Long &ls::std::boxing::Long::operator=(ls::std::core::type::long_type _value)
 {
   this->value = _value;
@@ -36,7 +31,7 @@ ls::std::core::type::long_type ls::std::boxing::Long::operator-() const
 
 ls::std::core::type::long_type ls::std::boxing::Long::operator+(const ls::std::boxing::Long &_long) const
 {
-  return this->value + _long;
+  return this->value + _long.getValue();
 }
 
 ls::std::core::type::long_type ls::std::boxing::Long::operator+(ls::std::core::type::long_type _value) const
@@ -46,7 +41,7 @@ ls::std::core::type::long_type ls::std::boxing::Long::operator+(ls::std::core::t
 
 ls::std::core::type::long_type ls::std::boxing::Long::operator*(const ls::std::boxing::Long &_long) const
 {
-  return this->value * _long;
+  return this->value * _long.getValue();
 }
 
 ls::std::core::type::long_type ls::std::boxing::Long::operator*(ls::std::core::type::long_type _value) const
@@ -56,7 +51,7 @@ ls::std::core::type::long_type ls::std::boxing::Long::operator*(ls::std::core::t
 
 ls::std::core::type::long_type ls::std::boxing::Long::operator-(const ls::std::boxing::Long &_long) const
 {
-  return this->value - _long;
+  return this->value - _long.getValue();
 }
 
 ls::std::core::type::long_type ls::std::boxing::Long::operator-(ls::std::core::type::long_type _value) const
@@ -71,7 +66,7 @@ ls::std::core::type::long_type ls::std::boxing::Long::operator/(const ls::std::b
     throw ls::std::core::IllegalArithmeticOperationException{"division by zero is not allowed"};
   }
 
-  return this->value / _long;
+  return this->value / _long.getValue();
 }
 
 ls::std::core::type::long_type ls::std::boxing::Long::operator/(ls::std::core::type::long_type _value) const
@@ -86,7 +81,7 @@ ls::std::core::type::long_type ls::std::boxing::Long::operator/(ls::std::core::t
 
 ls::std::core::type::long_type ls::std::boxing::Long::operator%(const ls::std::boxing::Long &_long) const
 {
-  return this->value % _long;
+  return this->value % _long.getValue();
 }
 
 ls::std::core::type::long_type ls::std::boxing::Long::operator%(ls::std::core::type::long_type _value) const
@@ -96,7 +91,7 @@ ls::std::core::type::long_type ls::std::boxing::Long::operator%(ls::std::core::t
 
 ls::std::boxing::Long &ls::std::boxing::Long::operator+=(const ls::std::boxing::Long &_long)
 {
-  this->value += _long;
+  this->value += _long.getValue();
   return *this;
 }
 
@@ -108,7 +103,7 @@ ls::std::boxing::Long &ls::std::boxing::Long::operator+=(ls::std::core::type::lo
 
 ls::std::boxing::Long &ls::std::boxing::Long::operator-=(const ls::std::boxing::Long &_long)
 {
-  this->value -= _long;
+  this->value -= _long.getValue();
   return *this;
 }
 
@@ -120,7 +115,7 @@ ls::std::boxing::Long &ls::std::boxing::Long::operator-=(ls::std::core::type::lo
 
 ls::std::boxing::Long &ls::std::boxing::Long::operator*=(const ls::std::boxing::Long &_long)
 {
-  this->value *= _long;
+  this->value *= _long.getValue();
   return *this;
 }
 
@@ -137,7 +132,7 @@ ls::std::boxing::Long &ls::std::boxing::Long::operator/=(const ls::std::boxing::
     throw ls::std::core::IllegalArithmeticOperationException{"division by zero is not allowed"};
   }
 
-  this->value /= _long;
+  this->value /= _long.getValue();
   return *this;
 }
 
@@ -154,7 +149,7 @@ ls::std::boxing::Long &ls::std::boxing::Long::operator/=(ls::std::core::type::lo
 
 bool ls::std::boxing::Long::operator==(const ls::std::boxing::Long &_long) const
 {
-  return this->value == _long;
+  return this->value == _long.getValue();
 }
 
 bool ls::std::boxing::Long::operator==(ls::std::core::type::long_type _value) const
@@ -164,7 +159,7 @@ bool ls::std::boxing::Long::operator==(ls::std::core::type::long_type _value) co
 
 bool ls::std::boxing::Long::operator!=(const ls::std::boxing::Long &_long) const
 {
-  return this->value != _long;
+  return this->value != _long.getValue();
 }
 
 bool ls::std::boxing::Long::operator!=(ls::std::core::type::long_type _value) const
@@ -174,7 +169,7 @@ bool ls::std::boxing::Long::operator!=(ls::std::core::type::long_type _value) co
 
 bool ls::std::boxing::Long::operator>(const ls::std::boxing::Long &_long) const
 {
-  return this->value > _long;
+  return this->value > _long.getValue();
 }
 
 bool ls::std::boxing::Long::operator>(ls::std::core::type::long_type _value) const
@@ -184,7 +179,7 @@ bool ls::std::boxing::Long::operator>(ls::std::core::type::long_type _value) con
 
 bool ls::std::boxing::Long::operator>=(const ls::std::boxing::Long &_long) const
 {
-  return this->value >= _long;
+  return this->value >= _long.getValue();
 }
 
 bool ls::std::boxing::Long::operator>=(ls::std::core::type::long_type _value) const
@@ -194,7 +189,7 @@ bool ls::std::boxing::Long::operator>=(ls::std::core::type::long_type _value) co
 
 bool ls::std::boxing::Long::operator<(const ls::std::boxing::Long &_long) const
 {
-  return this->value < _long;
+  return this->value < _long.getValue();
 }
 
 bool ls::std::boxing::Long::operator<(ls::std::core::type::long_type _value) const
@@ -204,7 +199,7 @@ bool ls::std::boxing::Long::operator<(ls::std::core::type::long_type _value) con
 
 bool ls::std::boxing::Long::operator<=(const ls::std::boxing::Long &_long) const
 {
-  return this->value <= _long;
+  return this->value <= _long.getValue();
 }
 
 bool ls::std::boxing::Long::operator<=(ls::std::core::type::long_type _value) const
@@ -214,7 +209,7 @@ bool ls::std::boxing::Long::operator<=(ls::std::core::type::long_type _value) co
 
 bool ls::std::boxing::Long::operator&&(const ls::std::boxing::Long &_long) const
 {
-  return this->value && _long;
+  return this->value && _long.getValue();
 }
 
 bool ls::std::boxing::Long::operator&&(ls::std::core::type::long_type _value) const
@@ -229,7 +224,7 @@ bool ls::std::boxing::Long::operator&&(bool _expression) const
 
 bool ls::std::boxing::Long::operator||(const ls::std::boxing::Long &_long) const
 {
-  return this->value || _long;
+  return this->value || _long.getValue();
 }
 
 bool ls::std::boxing::Long::operator||(ls::std::core::type::long_type _value) const

+ 15 - 15
test/cases/boxing/LongTest.cpp

@@ -41,7 +41,7 @@ namespace
     Long y{3};
     x = y;
 
-    ASSERT_EQ(3, x);
+    ASSERT_EQ(3, x.getValue());
   }
 
   TEST_F(LongTest, operator_assignment_with_value)
@@ -49,7 +49,7 @@ namespace
     Long x{13};
     x = (long_type) 3;
 
-    ASSERT_EQ(3, x);
+    ASSERT_EQ(3, x.getValue());
   }
 
   // arithmetic operators
@@ -177,7 +177,7 @@ namespace
     Long y{2};
     x += y;
 
-    ASSERT_EQ(6, x);
+    ASSERT_EQ(6, x.getValue());
   }
 
   TEST_F(LongTest, operator_add_equals_with_value)
@@ -185,7 +185,7 @@ namespace
     Long x{4};
     x += (long_type) 2;
 
-    ASSERT_EQ(6, x);
+    ASSERT_EQ(6, x.getValue());
   }
 
   TEST_F(LongTest, operator_sub_equals_with_reference)
@@ -194,7 +194,7 @@ namespace
     Long y{2};
     x -= y;
 
-    ASSERT_EQ(12, x);
+    ASSERT_EQ(12, x.getValue());
   }
 
   TEST_F(LongTest, operator_sub_equals_with_value)
@@ -202,7 +202,7 @@ namespace
     Long x{14};
     x -= (long_type) 2;
 
-    ASSERT_EQ(12, x);
+    ASSERT_EQ(12, x.getValue());
   }
 
   TEST_F(LongTest, operator_mul_equals_with_reference)
@@ -211,7 +211,7 @@ namespace
     Long y{3};
     x *= y;
 
-    ASSERT_EQ(18, x);
+    ASSERT_EQ(18, x.getValue());
   }
 
   TEST_F(LongTest, operator_mul_equals_with_value)
@@ -219,7 +219,7 @@ namespace
     Long x{6};
     x *= (long_type) 3;
 
-    ASSERT_EQ(18, x);
+    ASSERT_EQ(18, x.getValue());
   }
 
   TEST_F(LongTest, operator_div_equals_with_reference)
@@ -228,7 +228,7 @@ namespace
     Long y{3};
     x /= y;
 
-    ASSERT_EQ(4, x);
+    ASSERT_EQ(4, x.getValue());
   }
 
   TEST_F(LongTest, operator_div_equals_with_value)
@@ -236,7 +236,7 @@ namespace
     Long x{12};
     x /= (long_type) 3;
 
-    ASSERT_EQ(4, x);
+    ASSERT_EQ(4, x.getValue());
   }
 
   TEST_F(LongTest, operator_div_equals_by_zero_with_reference)
@@ -418,7 +418,7 @@ namespace
     Long x{};
     ++x;
 
-    ASSERT_EQ(1, x);
+    ASSERT_EQ(1, x.getValue());
   }
 
   TEST_F(LongTest, operator_decrement)
@@ -426,7 +426,7 @@ namespace
     Long x{};
     --x;
 
-    ASSERT_EQ(-1, x);
+    ASSERT_EQ(-1, x.getValue());
   }
 
   // implementation
@@ -436,7 +436,7 @@ namespace
     Long x{};
 
     x.parse("1989");
-    ASSERT_EQ(1989, x);
+    ASSERT_EQ(1989, x.getValue());
   }
 
   TEST_F(LongTest, parse_with_negative_value)
@@ -444,7 +444,7 @@ namespace
     Long x{};
 
     x.parse("-17");
-    ASSERT_EQ(-17, x);
+    ASSERT_EQ(-17, x.getValue());
   }
 
   TEST_F(LongTest, toString)
@@ -466,7 +466,7 @@ namespace
   TEST_F(LongTest, constApproach)
   {
     const Long x{3};
-    ASSERT_EQ(3, x);
+    ASSERT_EQ(3, x.getValue());
 
     // x = 4; // wouldn't work
   }