Skip to content

Commit 5ffd9a4

Browse files
committed
[fxp] Add tests that cover special cases in Fixed::checked_div_generic.
These tests guard against regression for the fix in commit 0e3bc33 ("[SQLLIB] Fix bug in DECIMAL division"). Signed-off-by: Ben Pfaff <blp@feldera.com>
1 parent 793bb5f commit 5ffd9a4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

crates/fxp/src/fixed.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,8 +1507,7 @@ mod test {
15071507

15081508
#[test]
15091509
fn div_generic() {
1510-
for a in -999..=999 {
1511-
let af: Fixed<10, 2> = Fixed(a);
1510+
fn test<const P: usize, const S: usize>(a: i128, af: Fixed<P, S>) {
15121511
for b in -999..=999 {
15131512
if b != 0 {
15141513
let bf: Fixed<10, 3> = Fixed(b);
@@ -1521,6 +1520,13 @@ mod test {
15211520
}
15221521
}
15231522
}
1523+
1524+
for a in -999..=999 {
1525+
let af: Fixed<10, 2> = Fixed(a);
1526+
test(a, af);
1527+
let af2: Fixed<18, 10> = af.convert().unwrap();
1528+
test(a, af2);
1529+
}
15241530
}
15251531

15261532
#[test]

0 commit comments

Comments
 (0)