From d15d8066d0ffe18242c256ff7592ed1481e9d6a2 Mon Sep 17 00:00:00 2001 From: William Baker Date: Sat, 2 Dec 2023 21:05:05 -0500 Subject: [PATCH] add addition tests --- tests/unit/overflow.hh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/unit/overflow.hh b/tests/unit/overflow.hh index f795674..d9a0fdc 100644 --- a/tests/unit/overflow.hh +++ b/tests/unit/overflow.hh @@ -26,6 +26,17 @@ testgroup (overflow) { auto result = first.multiply_with_overflow(second); test_assert(!result.first && result.second == INT24_C(0xe00000)); } + , testcase (add_not_overflow) { + int24_t n = INT24_C(0x700000); + auto result = n.add_with_overflow(n); + test_assert(!result.first && result.second == INT24_C(0xe00000)); + result = result.second.add_with_overflow(result.second); + test_assert(!result.first && result.second == INT24_C(-0x400000)); + } + , testcase (add_overflow) { + auto result = INT24_MIN.add_with_overflow(INT24_MIN); + test_assert(result.first); + } , testcase (inc_max) { int24_t x = INT24_MAX; ++x;