1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-01 05:27:45 +00:00

test/{seq,tr,truncate,unexpand}: fix build

This commit is contained in:
Michael Gehring 2014-11-20 20:45:52 +01:00
parent 92093644bb
commit 52ea352ca3
4 changed files with 24 additions and 24 deletions

View file

@ -5,28 +5,28 @@ static PROGNAME: &'static str = "./seq";
#[test] #[test]
fn test_count_up() { fn test_count_up() {
let p = Command::new(PROGNAME).args(["10"]).output().unwrap(); let p = Command::new(PROGNAME).args(&["10"]).output().unwrap();
let out = str::from_utf8(p.output.as_slice()).unwrap(); let out = str::from_utf8(p.output.as_slice()).unwrap();
assert_eq!(out, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n"); assert_eq!(out, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n");
} }
#[test] #[test]
fn test_count_down() { fn test_count_down() {
let p = Command::new(PROGNAME).args(["--", "5", "-1", "1"]).output().unwrap(); let p = Command::new(PROGNAME).args(&["--", "5", "-1", "1"]).output().unwrap();
let out = str::from_utf8(p.output.as_slice()).unwrap(); let out = str::from_utf8(p.output.as_slice()).unwrap();
assert_eq!(out, "5\n4\n3\n2\n1\n"); assert_eq!(out, "5\n4\n3\n2\n1\n");
} }
#[test] #[test]
fn test_separator_and_terminator() { fn test_separator_and_terminator() {
let p = Command::new(PROGNAME).args(["-s", ",", "-t", "!", "2", "6"]).output().unwrap(); let p = Command::new(PROGNAME).args(&["-s", ",", "-t", "!", "2", "6"]).output().unwrap();
let out = str::from_utf8(p.output.as_slice()).unwrap(); let out = str::from_utf8(p.output.as_slice()).unwrap();
assert_eq!(out, "2,3,4,5,6!"); assert_eq!(out, "2,3,4,5,6!");
} }
#[test] #[test]
fn test_equalize_widths() { fn test_equalize_widths() {
let p = Command::new(PROGNAME).args(["-w", "5", "10"]).output().unwrap(); let p = Command::new(PROGNAME).args(&["-w", "5", "10"]).output().unwrap();
let out = str::from_utf8(p.output.as_slice()).unwrap(); let out = str::from_utf8(p.output.as_slice()).unwrap();
assert_eq!(out, "05\n06\n07\n08\n09\n10\n"); assert_eq!(out, "05\n06\n07\n08\n09\n10\n");
} }

View file

@ -16,31 +16,31 @@ fn run(input: &str, args: &[&'static str]) -> Vec<u8> {
#[test] #[test]
fn test_toupper() { fn test_toupper() {
let out = run("!abcd!", ["a-z", "A-Z"]); let out = run("!abcd!", &["a-z", "A-Z"]);
assert_eq!(out.as_slice(), b"!ABCD!"); assert_eq!(out.as_slice(), b"!ABCD!");
} }
#[test] #[test]
fn test_small_set2() { fn test_small_set2() {
let out = run("@0123456789", ["0-9", "X"]); let out = run("@0123456789", &["0-9", "X"]);
assert_eq!(out.as_slice(), b"@XXXXXXXXXX"); assert_eq!(out.as_slice(), b"@XXXXXXXXXX");
} }
#[test] #[test]
fn test_unicode() { fn test_unicode() {
let out = run("(,°□°), ┬─┬", [", ┬─┬", "╯︵┻━┻"]); let out = run("(,°□°), ┬─┬", &[", ┬─┬", "╯︵┻━┻"]);
assert_eq!(out.as_slice(), "(╯°□°)╯︵┻━┻".as_bytes()); assert_eq!(out.as_slice(), "(╯°□°)╯︵┻━┻".as_bytes());
} }
#[test] #[test]
fn test_delete() { fn test_delete() {
let out = run("aBcD", ["-d", "a-z"]); let out = run("aBcD", &["-d", "a-z"]);
assert_eq!(out.as_slice(), b"BD"); assert_eq!(out.as_slice(), b"BD");
} }
#[test] #[test]
fn test_delete_complement() { fn test_delete_complement() {
let out = run("aBcD", ["-d", "-c", "a-z"]); let out = run("aBcD", &["-d", "-c", "a-z"]);
assert_eq!(out.as_slice(), b"ac"); assert_eq!(out.as_slice(), b"ac");
} }

View file

@ -15,7 +15,7 @@ fn make_file(name: &str) -> io::File {
#[test] #[test]
fn test_increase_file_size() { fn test_increase_file_size() {
let mut file = make_file(TFILE1); let mut file = make_file(TFILE1);
if !Command::new(PROGNAME).args(["-s", "+5K", TFILE1]).status().unwrap().success() { if !Command::new(PROGNAME).args(&["-s", "+5K", TFILE1]).status().unwrap().success() {
panic!(); panic!();
} }
file.seek(0, io::SeekEnd).unwrap(); file.seek(0, io::SeekEnd).unwrap();
@ -29,7 +29,7 @@ fn test_increase_file_size() {
fn test_decrease_file_size() { fn test_decrease_file_size() {
let mut file = make_file(TFILE2); let mut file = make_file(TFILE2);
file.write(b"1234567890").unwrap(); file.write(b"1234567890").unwrap();
if !Command::new(PROGNAME).args(["--size=-4", TFILE2]).status().unwrap().success() { if !Command::new(PROGNAME).args(&["--size=-4", TFILE2]).status().unwrap().success() {
panic!(); panic!();
} }
file.seek(0, io::SeekEnd).unwrap(); file.seek(0, io::SeekEnd).unwrap();

View file

@ -16,56 +16,56 @@ fn run(input: &str, args: &[&'static str]) -> Vec<u8> {
#[test] #[test]
fn unexpand_init_0() { fn unexpand_init_0() {
let out = run(" 1\n 2\n 3\n 4\n", ["-t4"]); let out = run(" 1\n 2\n 3\n 4\n", &["-t4"]);
assert_eq!(out.as_slice(), b" 1\n 2\n 3\n\t4\n"); assert_eq!(out.as_slice(), b" 1\n 2\n 3\n\t4\n");
} }
#[test] #[test]
fn unexpand_init_1() { fn unexpand_init_1() {
let out = run(" 5\n 6\n 7\n 8\n", ["-t4"]); let out = run(" 5\n 6\n 7\n 8\n", &["-t4"]);
assert_eq!(out.as_slice(), b"\t 5\n\t 6\n\t 7\n\t\t8\n"); assert_eq!(out.as_slice(), b"\t 5\n\t 6\n\t 7\n\t\t8\n");
} }
#[test] #[test]
fn unexpand_init_list_0() { fn unexpand_init_list_0() {
let out = run(" 1\n 2\n 3\n 4\n", ["-t2,4"]); let out = run(" 1\n 2\n 3\n 4\n", &["-t2,4"]);
assert_eq!(out.as_slice(), b" 1\n\t2\n\t 3\n\t\t4\n"); assert_eq!(out.as_slice(), b" 1\n\t2\n\t 3\n\t\t4\n");
} }
#[test] #[test]
fn unexpand_init_list_1() { fn unexpand_init_list_1() {
// Once the list is exhausted, spaces are not converted anymore // Once the list is exhausted, spaces are not converted anymore
let out = run(" 5\n 6\n 7\n 8\n", ["-t2,4"]); let out = run(" 5\n 6\n 7\n 8\n", &["-t2,4"]);
assert_eq!(out.as_slice(), b"\t\t 5\n\t\t 6\n\t\t 7\n\t\t 8\n"); assert_eq!(out.as_slice(), b"\t\t 5\n\t\t 6\n\t\t 7\n\t\t 8\n");
} }
#[test] #[test]
fn unexpand_aflag_0() { fn unexpand_aflag_0() {
let out = run("e E\nf F\ng G\nh H\n", []); let out = run("e E\nf F\ng G\nh H\n", &[]);
assert_eq!(out.as_slice(), b"e E\nf F\ng G\nh H\n"); assert_eq!(out.as_slice(), b"e E\nf F\ng G\nh H\n");
} }
#[test] #[test]
fn unexpand_aflag_1() { fn unexpand_aflag_1() {
let out = run("e E\nf F\ng G\nh H\n", ["-a"]); let out = run("e E\nf F\ng G\nh H\n", &["-a"]);
assert_eq!(out.as_slice(), b"e E\nf F\ng\tG\nh\t H\n"); assert_eq!(out.as_slice(), b"e E\nf F\ng\tG\nh\t H\n");
} }
#[test] #[test]
fn unexpand_aflag_2() { fn unexpand_aflag_2() {
let out = run("e E\nf F\ng G\nh H\n", ["-t8"]); let out = run("e E\nf F\ng G\nh H\n", &["-t8"]);
assert_eq!(out.as_slice(), b"e E\nf F\ng\tG\nh\t H\n"); assert_eq!(out.as_slice(), b"e E\nf F\ng\tG\nh\t H\n");
} }
#[test] #[test]
fn unexpand_first_only_0() { fn unexpand_first_only_0() {
let out = run(" A B", ["-t3"]); let out = run(" A B", &["-t3"]);
assert_eq!(out.as_slice(), b"\t\t A\t B"); assert_eq!(out.as_slice(), b"\t\t A\t B");
} }
#[test] #[test]
fn unexpand_first_only_1() { fn unexpand_first_only_1() {
let out = run(" A B", ["-t3", "--first-only"]); let out = run(" A B", &["-t3", "--first-only"]);
assert_eq!(out.as_slice(), b"\t\t A B"); assert_eq!(out.as_slice(), b"\t\t A B");
} }
@ -73,20 +73,20 @@ fn unexpand_first_only_1() {
fn unexpand_trailing_space_0() { // evil fn unexpand_trailing_space_0() { // evil
// Individual spaces before fields starting with non blanks should not be // Individual spaces before fields starting with non blanks should not be
// converted, unless they are at the beginning of the line. // converted, unless they are at the beginning of the line.
let out = run("123 \t1\n123 1\n123 \n123 ", ["-t4"]); let out = run("123 \t1\n123 1\n123 \n123 ", &["-t4"]);
assert_eq!(out.as_slice(), b"123\t\t1\n123 1\n123 \n123 "); assert_eq!(out.as_slice(), b"123\t\t1\n123 1\n123 \n123 ");
} }
#[test] #[test]
fn unexpand_trailing_space_1() { // super evil fn unexpand_trailing_space_1() { // super evil
let out = run(" abc d e f g ", ["-t1"]); let out = run(" abc d e f g ", &["-t1"]);
assert_eq!(out.as_slice(), b"\tabc d e\t\tf\t\tg "); assert_eq!(out.as_slice(), b"\tabc d e\t\tf\t\tg ");
} }
#[test] #[test]
fn unexpand_spaces_follow_tabs_0() { fn unexpand_spaces_follow_tabs_0() {
// The two first spaces can be included into the first tab. // The two first spaces can be included into the first tab.
let out = run(" \t\t A", []); let out = run(" \t\t A", &[]);
assert_eq!(out.as_slice(), b"\t\t A"); assert_eq!(out.as_slice(), b"\t\t A");
} }
@ -97,7 +97,7 @@ fn unexpand_spaces_follow_tabs_1() { // evil
// ' \t' -> '\t' // second tabstop (4) // ' \t' -> '\t' // second tabstop (4)
// ' ' -> '\t' // third tabstop (5) // ' ' -> '\t' // third tabstop (5)
// ' B \t' -> ' B \t' // after the list is exhausted, nothing must change // ' B \t' -> ' B \t' // after the list is exhausted, nothing must change
let out = run("a \t B \t", ["-t1,4,5"]); let out = run("a \t B \t", &["-t1,4,5"]);
assert_eq!(out.as_slice(), b"a\t\t B \t"); assert_eq!(out.as_slice(), b"a\t\t B \t");
} }