From c6d494513efbf39eb2183e2c620a110c925f2043 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Thu, 5 Jan 2023 21:14:23 +0300 Subject: [PATCH] AK: Fix typo in -= operator of DistinctNumeric --- AK/DistinctNumeric.h | 4 ++-- Tests/AK/TestDistinctNumeric.cpp | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/AK/DistinctNumeric.h b/AK/DistinctNumeric.h index 1e0525ae7e9..a106cb9a033 100644 --- a/AK/DistinctNumeric.h +++ b/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) diff --git a/Tests/AK/TestDistinctNumeric.cpp b/Tests/AK/TestDistinctNumeric.cpp index e8b398b7402..210faee8e5e 100644 --- a/Tests/AK/TestDistinctNumeric.cpp +++ b/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)