diff options
author | Merry <[email protected]> | 2023-01-15 23:59:27 +0000 |
---|---|---|
committer | Merry <[email protected]> | 2023-01-15 23:59:27 +0000 |
commit | 4f3ef50d5c6e3bb4ee0753e7161b9e0ce010d4b8 (patch) | |
tree | 4a2e461fe424628286cbf27336b12cf8f4690d64 /tests | |
parent | f3af94bc7ca4812d3a3ed91293bf133ed6dccb9d (diff) | |
download | dynarmic-4f3ef50d5c6e3bb4ee0753e7161b9e0ce010d4b8.tar.gz dynarmic-4f3ef50d5c6e3bb4ee0753e7161b9e0ce010d4b8.zip |
fp: Fix FPToFixed for borderline values
Diffstat (limited to 'tests')
-rw-r--r-- | tests/fp/FPToFixed.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/fp/FPToFixed.cpp b/tests/fp/FPToFixed.cpp index 2d1deb5e..31a684a6 100644 --- a/tests/fp/FPToFixed.cpp +++ b/tests/fp/FPToFixed.cpp @@ -38,3 +38,20 @@ TEST_CASE("FPToFixed", "[fp]") { REQUIRE(fpsr.Value() == expected_fpsr); } } + +TEST_CASE("FPToFixed edge cases", "[fp]") { + const std::vector<std::tuple<u64, u64, bool, FP::RoundingMode>> test_cases{ + {0x41dffffffffffffe, 0x7fffffff, false, FP::RoundingMode::ToNearest_TieEven}, + {0x41dffffffffffffe, 0x7fffffff, false, FP::RoundingMode::TowardsPlusInfinity}, + {0x41dffffffffffffe, 0x7fffffff, false, FP::RoundingMode::TowardsMinusInfinity}, + {0x41dffffffffffffe, 0x7fffffff, false, FP::RoundingMode::TowardsZero}, + {0x41dffffffffffffe, 0x7fffffff, false, FP::RoundingMode::ToNearest_TieAwayFromZero}, + }; + + const FPCR fpcr; + FPSR fpsr; + for (auto [input, expected_output, unsigned_, rounding_mode] : test_cases) { + const u64 output = FPToFixed<u64>(32, input, 0, unsigned_, fpcr, rounding_mode, fpsr); + REQUIRE(output == expected_output); + } +} |