Skip to content

Commit 7aa46dd

Browse files
committed
test(cksum): nits on tests
1 parent dfda5e0 commit 7aa46dd

File tree

1 file changed

+14
-34
lines changed

1 file changed

+14
-34
lines changed

tests/by-util/test_cksum.rs

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@ fn test_one_nonexisting_file() {
118118
// but <128 bytes (1 fold pclmul) // spell-checker:disable-line
119119
#[test]
120120
fn test_crc_for_bigger_than_32_bytes() {
121-
let (_, mut ucmd) = at_and_ucmd!();
122-
123-
let result = ucmd.arg("chars.txt").succeeds();
121+
let result = new_ucmd!().arg("chars.txt").succeeds();
124122

125123
let mut stdout_split = result.stdout_str().split(' ');
126124

@@ -133,9 +131,7 @@ fn test_crc_for_bigger_than_32_bytes() {
133131

134132
#[test]
135133
fn test_stdin_larger_than_128_bytes() {
136-
let (_, mut ucmd) = at_and_ucmd!();
137-
138-
let result = ucmd.arg("larger_than_2056_bytes.txt").succeeds();
134+
let result = new_ucmd!().arg("larger_than_2056_bytes.txt").succeeds();
139135

140136
let mut stdout_split = result.stdout_str().split(' ');
141137

@@ -298,34 +294,18 @@ fn test_untagged_algorithm_stdin() {
298294

299295
#[test]
300296
fn test_check_algo() {
301-
new_ucmd!()
302-
.arg("-a=bsd")
303-
.arg("--check")
304-
.arg("lorem_ipsum.txt")
305-
.fails()
306-
.no_stdout()
307-
.stderr_contains("cksum: --check is not supported with --algorithm={bsd,sysv,crc,crc32b}");
308-
new_ucmd!()
309-
.arg("-a=sysv")
310-
.arg("--check")
311-
.arg("lorem_ipsum.txt")
312-
.fails_with_code(1)
313-
.no_stdout()
314-
.stderr_contains("cksum: --check is not supported with --algorithm={bsd,sysv,crc,crc32b}");
315-
new_ucmd!()
316-
.arg("-a=crc")
317-
.arg("--check")
318-
.arg("lorem_ipsum.txt")
319-
.fails_with_code(1)
320-
.no_stdout()
321-
.stderr_contains("cksum: --check is not supported with --algorithm={bsd,sysv,crc,crc32b}");
322-
new_ucmd!()
323-
.arg("-a=crc32b")
324-
.arg("--check")
325-
.arg("lorem_ipsum.txt")
326-
.fails_with_code(1)
327-
.no_stdout()
328-
.stderr_contains("cksum: --check is not supported with --algorithm={bsd,sysv,crc,crc32b}");
297+
for algo in ["bsd", "sysv", "crc", "crc32b"] {
298+
new_ucmd!()
299+
.arg("-a")
300+
.arg(algo)
301+
.arg("--check")
302+
.arg("lorem_ipsum.txt")
303+
.fails()
304+
.no_stdout()
305+
.stderr_contains(
306+
"cksum: --check is not supported with --algorithm={bsd,sysv,crc,crc32b}",
307+
);
308+
}
329309
}
330310

331311
#[test]

0 commit comments

Comments
 (0)