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

hashsum: add tests for Windows text mode

This commit is contained in:
Jeffrey Finkelstein 2021-09-16 22:33:04 -04:00
parent 3e458f524c
commit cd5f676903

View file

@ -38,6 +38,30 @@ macro_rules! test_digest {
.no_stderr() .no_stderr()
.stdout_is("input.txt: OK\n"); .stdout_is("input.txt: OK\n");
} }
#[cfg(windows)]
#[test]
fn test_text_mode() {
// TODO Replace this with hard-coded files that store the
// expected output of text mode on an input file that has
// "\r\n" line endings.
let result = new_ucmd!()
.args(&[DIGEST_ARG, BITS_ARG, "-b"])
.pipe_in("a\nb\nc\n")
.succeeds();
let expected = result.no_stderr().stdout();
// Replace the "*-\n" at the end of the output with " -\n".
// The asterisk indicates that the digest was computed in
// binary mode.
let n = expected.len();
let expected = [&expected[..n - 3], &[b' ', b'-', b'\n']].concat();
new_ucmd!()
.args(&[DIGEST_ARG, BITS_ARG, "-t"])
.pipe_in("a\r\nb\r\nc\r\n")
.succeeds()
.no_stderr()
.stdout_is(std::str::from_utf8(&expected).unwrap());
}
} }
)*) )*)
} }