diff options
| author | batsumaru <> | 2026-08-09 12:39:50 +0900 |
|---|---|---|
| committer | batsumaru <> | 2026-08-09 12:39:50 +0900 |
| commit | 7bb49794297b46aa1c577e89da24d39b4348c6d4 (patch) | |
| tree | 89b1d4a1f044546e15fbbd0dde370eddc6e7b4b9 /tests/test_fixed_point.cpp | |
| parent | 9d4f68606c919791d44e86e7a50812c29be32fa3 (diff) | |
Added fp_t multiplication
Diffstat (limited to 'tests/test_fixed_point.cpp')
| -rw-r--r-- | tests/test_fixed_point.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_fixed_point.cpp b/tests/test_fixed_point.cpp index b116340..6d1a594 100644 --- a/tests/test_fixed_point.cpp +++ b/tests/test_fixed_point.cpp @@ -17,6 +17,13 @@ TEST_CASE("fp_t subtraction anti-commutative") { REQUIRE(a.raw != 0); } +TEST_CASE("fp_t multiplication is commutative") { + fp_t a = fp_t::from_int(2); + fp_t b = fp_t::from_int(5); + CHECK(a * b == b * a); + REQUIRE(a.raw != 1); +} + TEST_CASE("fp_t addition overflows") { fp_t a = fp_t::from_raw(INT32_MAX); fp_t b = fp_t::from_raw(1); @@ -30,3 +37,16 @@ TEST_CASE("fp_t subtraction underflows") { fp_t c = fp_t::from_raw(INT32_MAX); CHECK(a - b == c); } + +TEST_CASE("fp_t multiplication overflows") { + fp_t a = fp_t::from_raw(INT32_MAX); + fp_t b = fp_t::from_int(2); + fp_t c = fp_t::from_raw(-2); + CHECK(a * b == c); +} + +TEST_CASE("fp_t multiplication drops percision under 1 ULP") { + fp_t a = fp_t::from_raw(1); + fp_t b = fp_t::from_raw(0); + CHECK(a * a == b); +} |
