Skip to content

Commit 02d423c

Browse files
quaternictgross35
authored andcommitted
add cases to NarrowingDiv unit test
1 parent 00aee3d commit 02d423c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

libm/src/math/support/int_traits/narrowing_div.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,17 @@ mod test {
157157
for y in 1..=u8::MAX {
158158
let xy = x.widen_mul(y);
159159
assert_eq!(xy.checked_narrowing_div_rem(y), Some((x, 0)));
160+
assert_eq!(
161+
(xy + (y - 1) as u16).checked_narrowing_div_rem(y),
162+
Some((x, y - 1))
163+
);
164+
if y > 1 {
165+
assert_eq!((xy + 1).checked_narrowing_div_rem(y), Some((x, 1)));
166+
assert_eq!(
167+
(xy + (y - 2) as u16).checked_narrowing_div_rem(y),
168+
Some((x, y - 2))
169+
);
170+
}
160171
}
161172
}
162173
}

0 commit comments

Comments
 (0)