Skip to content

Commit 72060b7

Browse files
committed
Extend test_format_u8 to include u8::MAX
This is equivalent to looping 0..=u8::MAX, except that `..=` syntax is not supported on old rustc and `...` syntax is not supported on new rustc, so loop it is.
1 parent 1bb23ad commit 72060b7

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

‎serde/src/ser/impls.rs‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -706,10 +706,17 @@ fn format_u8(mut n: u8, out: &mut [u8]) -> usize {
706706
#[cfg(feature = "std")]
707707
#[test]
708708
fn test_format_u8() {
709-
for i in 0..(u8::MAX as u16) {
709+
let mut i = 0u8;
710+
711+
loop {
710712
let mut buf = [0u8; 3];
711-
let written = format_u8(i as u8, &mut buf);
713+
let written = format_u8(i, &mut buf);
712714
assert_eq!(i.to_string().as_bytes(), &buf[..written]);
715+
716+
match i.checked_add(1) {
717+
Some(next) => i = next,
718+
None => break,
719+
}
713720
}
714721
}
715722

0 commit comments

Comments
 (0)