1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Fix various 'if_then_panic' clippy warnings

This commit is contained in:
Sylvestre Ledru 2021-10-10 09:57:39 +02:00
parent 32ec3f75ee
commit 00de952592
3 changed files with 42 additions and 59 deletions

View file

@ -35,9 +35,10 @@ fn test_file() {
{
let mut f = File::create(&file).unwrap();
// spell-checker:disable-next-line
if f.write_all(b"abcdefghijklmnopqrstuvwxyz\n").is_err() {
panic!("Test setup failed - could not write file");
}
assert!(
!f.write_all(b"abcdefghijklmnopqrstuvwxyz\n").is_err(),
"Test setup failed - could not write file"
);
}
new_ucmd!()
@ -75,9 +76,10 @@ fn test_2files() {
// spell-checker:disable-next-line
for &(path, data) in &[(&file1, "abcdefghijklmnop"), (&file2, "qrstuvwxyz\n")] {
let mut f = File::create(&path).unwrap();
if f.write_all(data.as_bytes()).is_err() {
panic!("Test setup failed - could not write file");
}
assert!(
!f.write_all(data.as_bytes()).is_err(),
"Test setup failed - could not write file"
);
}
new_ucmd!()
@ -126,9 +128,10 @@ fn test_from_mixed() {
let (data1, data2, data3) = ("abcdefg", "hijklmnop", "qrstuvwxyz\n");
for &(path, data) in &[(&file1, data1), (&file3, data3)] {
let mut f = File::create(&path).unwrap();
if f.write_all(data.as_bytes()).is_err() {
panic!("Test setup failed - could not write file");
}
assert!(
!f.write_all(data.as_bytes()).is_err(),
"Test setup failed - could not write file"
);
}
new_ucmd!()