Selaa lähdekoodia

AK: Fix typo in -= operator of DistinctNumeric

Aliaksandr Kalenik 2 vuotta sitten
vanhempi
commit
c6d494513e
2 muutettua tiedostoa jossa 6 lisäystä ja 2 poistoa
  1. 2 2
      AK/DistinctNumeric.h
  2. 4 0
      Tests/AK/TestDistinctNumeric.cpp

+ 2 - 2
AK/DistinctNumeric.h

@@ -286,8 +286,8 @@ public:
     }
     constexpr Self& operator-=(Self const& other)
     {
-        static_assert(options.arithmetic, "'a+=b' is only available for DistinctNumeric types with 'Arithmetic'.");
-        this->m_value += other.m_value;
+        static_assert(options.arithmetic, "'a-=b' is only available for DistinctNumeric types with 'Arithmetic'.");
+        this->m_value -= other.m_value;
         return *this;
     }
     constexpr Self& operator*=(Self const& other)

+ 4 - 0
Tests/AK/TestDistinctNumeric.cpp

@@ -197,6 +197,10 @@ TEST_CASE(operator_arith)
     EXPECT_EQ(a, ArithNumeric(1));
     EXPECT_EQ(a %= a, ArithNumeric(0));
     EXPECT_EQ(a, ArithNumeric(0));
+
+    a = ArithNumeric(12);
+    EXPECT_EQ(a -= a, ArithNumeric(0));
+    EXPECT_EQ(a, ArithNumeric(0));
 }
 
 TEST_CASE(composability)