Skip to content

Commit

Permalink
Let DecInt tests ensure valid CStrs are formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
Kijewski committed Dec 21, 2024
1 parent 080dcdc commit ca6606c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/path/dec_int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ use rustix::path::DecInt;
macro_rules! check {
($i:expr) => {
let i = $i;
assert_eq!(DecInt::new(i).as_ref().to_str().unwrap(), i.to_string());
assert_eq!(
DecInt::new(i).as_c_str().to_bytes_with_nul(),
format!("{i}\0").as_bytes(),
);
};
}

Expand All @@ -30,4 +33,11 @@ fn test_dec_int() {
check!(usize::MAX);
check!(isize::MIN);
}

for i in u16::MIN..=u16::MAX {
check!(i);
}
for i in i16::MIN..=i16::MAX {
check!(i);
}
}

0 comments on commit ca6606c

Please sign in to comment.