mirror of
https://github.com/uutils/coreutils
synced 2024-12-24 12:03:24 +00:00
7ef4bb37a8
The main motivation is to move toward running those tests for a specific target, that is, if a test won't run on Windows, then we shouldn't build it. This was previously the default behavior and prevented a successful run on AppVeyor. I borrowed this pattern from the tests in the Cargo project.
56 lines
1.9 KiB
Rust
56 lines
1.9 KiB
Rust
use common::util::*;
|
|
|
|
static UTIL_NAME: &'static str = "cat";
|
|
|
|
#[test]
|
|
fn test_output_multi_files_print_all_chars() {
|
|
let (_, mut ucmd) = testing(UTIL_NAME);
|
|
ucmd.arg("alpha.txt")
|
|
.arg("256.txt")
|
|
.arg("-A")
|
|
.arg("-n");
|
|
|
|
assert_eq!(ucmd.run().stdout,
|
|
" 1\tabcde$\n 2\tfghij$\n 3\tklmno$\n 4\tpqrst$\n \
|
|
5\tuvwxyz$\n 6\t^@^A^B^C^D^E^F^G^H^I$\n \
|
|
7\t^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\\^]^^^_ \
|
|
!\"#$%&\'()*+,-./0123456789:;\
|
|
<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~^?M-^@M-^AM-^\
|
|
BM-^CM-^DM-^EM-^FM-^GM-^HM-^IM-^JM-^KM-^LM-^MM-^NM-^OM-^PM-^QM-^RM-^SM-^TM-^UM-^V\
|
|
M-^WM-^XM-^YM-^ZM-^[M-^\\M-^]M-^^M-^_M- \
|
|
M-!M-\"M-#M-$M-%M-&M-\'M-(M-)M-*M-+M-,M--M-.M-/M-0M-1M-2M-3M-4M-5M-6M-7M-8M-9M-:\
|
|
M-;M-<M-=M->M-?M-@M-AM-BM-CM-DM-EM-FM-GM-HM-IM-JM-KM-LM-MM-NM-OM-PM-QM-RM-SM-TM-U\
|
|
M-VM-WM-XM-YM-ZM-[M-\\M-]M-^M-_M-`M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-oM-\
|
|
pM-qM-rM-sM-tM-uM-vM-wM-xM-yM-zM-{M-|M-}M-~M-^?");
|
|
}
|
|
|
|
#[test]
|
|
fn test_stdin_show_all() {
|
|
let (_, mut ucmd) = testing(UTIL_NAME);
|
|
let out = ucmd.arg("-A")
|
|
.run_piped_stdin("\x00\x01\x02".as_bytes())
|
|
.stdout;
|
|
|
|
assert_eq!(out, "^@^A^B");
|
|
}
|
|
|
|
#[test]
|
|
fn test_stdin_squeeze_blank() {
|
|
let (_, mut ucmd) = testing(UTIL_NAME);
|
|
let out = ucmd.arg("--squeeze-blank")
|
|
.run_piped_stdin("\n\na\n\n\n\n\nb\n\n\n".as_bytes())
|
|
.stdout;
|
|
|
|
assert_eq!(out, "\na\n\nb\n\n");
|
|
}
|
|
|
|
#[test]
|
|
fn test_stdin_number_non_blank() {
|
|
let (_, mut ucmd) = testing(UTIL_NAME);
|
|
let out = ucmd.arg("-b")
|
|
.arg("-")
|
|
.run_piped_stdin("\na\nb\n\n\nc".as_bytes())
|
|
.stdout;
|
|
|
|
assert_eq!(out, "\n 1\ta\n 2\tb\n\n\n 3\tc");
|
|
}
|