summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbatsumaru <>2026-08-09 11:28:19 +0900
committerbatsumaru <>2026-08-09 11:28:19 +0900
commit28fd42b64ae2878114225bea8ede2fb16d466908 (patch)
tree388b1ca2ee14d25d7741f8a62b185e116dd954c5
parent6fec4f36122ce8ea59aca51b9ff6bce1210d676a (diff)
Test for explict overflow
-rw-r--r--tests/test_fixed_point.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/test_fixed_point.cpp b/tests/test_fixed_point.cpp
index 8cb12d2..b3d3e78 100644
--- a/tests/test_fixed_point.cpp
+++ b/tests/test_fixed_point.cpp
@@ -7,3 +7,10 @@ TEST_CASE("fp_t addition is commutative") {
CHECK(a + b == b + a);
REQUIRE(a.raw != 0);
}
+
+TEST_CASE("fp_t addition overflows") {
+ fp_t a = fp_t::from_raw(INT32_MAX);
+ fp_t b = fp_t::from_raw(1);
+ fp_t c = fp_t::from_raw(INT32_MIN);
+ CHECK(a + b == c);
+}