Skip to content

Commit

Permalink
add addition tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bbrk24 committed Dec 3, 2023
1 parent 558aa63 commit d15d806
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/unit/overflow.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d15d806

Please sign in to comment.