mirror of
https://github.com/uutils/coreutils
synced 2024-11-16 01:38:04 +00:00
commit
ad8724e84e
7 changed files with 104 additions and 0 deletions
1
Makefile
1
Makefile
|
@ -183,6 +183,7 @@ TEST_PROGS := \
|
||||||
seq \
|
seq \
|
||||||
sort \
|
sort \
|
||||||
split \
|
split \
|
||||||
|
tac \
|
||||||
test \
|
test \
|
||||||
tr \
|
tr \
|
||||||
true \
|
true \
|
||||||
|
|
1
test/fixtures/tac/delimited_primes.expected
vendored
Normal file
1
test/fixtures/tac/delimited_primes.expected
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
9789:83:79:73:71:67:61:59:53:47:43:41:37:31:29:23:19:17:13:11:7:5:3:2:
|
1
test/fixtures/tac/delimited_primes.txt
vendored
Normal file
1
test/fixtures/tac/delimited_primes.txt
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
2:3:5:7:11:13:17:19:23:29:31:37:41:43:47:53:59:61:67:71:73:79:83:89:97
|
1
test/fixtures/tac/delimited_primes_before.expected
vendored
Normal file
1
test/fixtures/tac/delimited_primes_before.expected
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
97:89:83:79:73:71:67:61:59:53:47:43:41:37:31:29:23:19:17:13:11:7:5:3:2
|
25
test/fixtures/tac/prime_per_line.expected
vendored
Normal file
25
test/fixtures/tac/prime_per_line.expected
vendored
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
97
|
||||||
|
89
|
||||||
|
83
|
||||||
|
79
|
||||||
|
73
|
||||||
|
71
|
||||||
|
67
|
||||||
|
61
|
||||||
|
59
|
||||||
|
53
|
||||||
|
47
|
||||||
|
43
|
||||||
|
41
|
||||||
|
37
|
||||||
|
31
|
||||||
|
29
|
||||||
|
23
|
||||||
|
19
|
||||||
|
17
|
||||||
|
13
|
||||||
|
11
|
||||||
|
7
|
||||||
|
5
|
||||||
|
3
|
||||||
|
2
|
25
test/fixtures/tac/prime_per_line.txt
vendored
Normal file
25
test/fixtures/tac/prime_per_line.txt
vendored
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
2
|
||||||
|
3
|
||||||
|
5
|
||||||
|
7
|
||||||
|
11
|
||||||
|
13
|
||||||
|
17
|
||||||
|
19
|
||||||
|
23
|
||||||
|
29
|
||||||
|
31
|
||||||
|
37
|
||||||
|
41
|
||||||
|
43
|
||||||
|
47
|
||||||
|
53
|
||||||
|
59
|
||||||
|
61
|
||||||
|
67
|
||||||
|
71
|
||||||
|
73
|
||||||
|
79
|
||||||
|
83
|
||||||
|
89
|
||||||
|
97
|
50
test/tac.rs
Normal file
50
test/tac.rs
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
use std::process::Command;
|
||||||
|
use util::*;
|
||||||
|
|
||||||
|
static PROGNAME: &'static str = "./tac";
|
||||||
|
|
||||||
|
#[path = "common/util.rs"]
|
||||||
|
#[macro_use]
|
||||||
|
mod util;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_stdin_default() {
|
||||||
|
let mut cmd = Command::new(PROGNAME);
|
||||||
|
let result = run_piped_stdin(&mut cmd, "100\n200\n300\n400\n500");
|
||||||
|
assert_eq!(result.stdout, "500400\n300\n200\n100\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_stdin_non_newline_separator() {
|
||||||
|
let mut cmd = Command::new(PROGNAME);
|
||||||
|
let result = run_piped_stdin(&mut cmd.args(&["-s", ":"]), "100:200:300:400:500");
|
||||||
|
assert_eq!(result.stdout, "500400:300:200:100:");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_stdin_non_newline_separator_before() {
|
||||||
|
let mut cmd = Command::new(PROGNAME);
|
||||||
|
let result = run_piped_stdin(&mut cmd.args(&["-b", "-s", ":"]), "100:200:300:400:500");
|
||||||
|
assert_eq!(result.stdout, "500:400:300:200:100");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_single_default() {
|
||||||
|
let mut cmd = Command::new(PROGNAME);
|
||||||
|
let result = run(&mut cmd.arg("prime_per_line.txt"));
|
||||||
|
assert_eq!(result.stdout, get_file_contents("prime_per_line.expected"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_single_non_newline_separator() {
|
||||||
|
let mut cmd = Command::new(PROGNAME);
|
||||||
|
let result = run(&mut cmd.args(&["-s", ":", "delimited_primes.txt"]));
|
||||||
|
assert_eq!(result.stdout, get_file_contents("delimited_primes.expected"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_single_non_newline_separator_before() {
|
||||||
|
let mut cmd = Command::new(PROGNAME);
|
||||||
|
let result = run(&mut cmd.args(&["-b", "-s", ":", "delimited_primes.txt"]));
|
||||||
|
assert_eq!(result.stdout, get_file_contents("delimited_primes_before.expected"));
|
||||||
|
}
|
Loading…
Reference in a new issue