mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-31 13:07:46 +00:00
test/{seq,tr,truncate,unexpand}: fix build
This commit is contained in:
parent
92093644bb
commit
52ea352ca3
4 changed files with 24 additions and 24 deletions
|
@ -5,28 +5,28 @@ static PROGNAME: &'static str = "./seq";
|
|||
|
||||
#[test]
|
||||
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();
|
||||
assert_eq!(out, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
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();
|
||||
assert_eq!(out, "5\n4\n3\n2\n1\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
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();
|
||||
assert_eq!(out, "2,3,4,5,6!");
|
||||
}
|
||||
|
||||
#[test]
|
||||
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();
|
||||
assert_eq!(out, "05\n06\n07\n08\n09\n10\n");
|
||||
}
|
||||
|
|
10
test/tr.rs
10
test/tr.rs
|
@ -16,31 +16,31 @@ fn run(input: &str, args: &[&'static str]) -> Vec<u8> {
|
|||
|
||||
#[test]
|
||||
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!");
|
||||
}
|
||||
|
||||
#[test]
|
||||
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");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_unicode() {
|
||||
let out = run("(,°□°), ┬─┬", [", ┬─┬", "╯︵┻━┻"]);
|
||||
let out = run("(,°□°), ┬─┬", &[", ┬─┬", "╯︵┻━┻"]);
|
||||
assert_eq!(out.as_slice(), "(╯°□°)╯︵┻━┻".as_bytes());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_delete() {
|
||||
let out = run("aBcD", ["-d", "a-z"]);
|
||||
let out = run("aBcD", &["-d", "a-z"]);
|
||||
assert_eq!(out.as_slice(), b"BD");
|
||||
}
|
||||
|
||||
#[test]
|
||||
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");
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ fn make_file(name: &str) -> io::File {
|
|||
#[test]
|
||||
fn test_increase_file_size() {
|
||||
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!();
|
||||
}
|
||||
file.seek(0, io::SeekEnd).unwrap();
|
||||
|
@ -29,7 +29,7 @@ fn test_increase_file_size() {
|
|||
fn test_decrease_file_size() {
|
||||
let mut file = make_file(TFILE2);
|
||||
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!();
|
||||
}
|
||||
file.seek(0, io::SeekEnd).unwrap();
|
||||
|
|
|
@ -16,56 +16,56 @@ fn run(input: &str, args: &[&'static str]) -> Vec<u8> {
|
|||
|
||||
#[test]
|
||||
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");
|
||||
}
|
||||
|
||||
#[test]
|
||||
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");
|
||||
}
|
||||
|
||||
#[test]
|
||||
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");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unexpand_init_list_1() {
|
||||
// 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");
|
||||
}
|
||||
|
||||
#[test]
|
||||
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");
|
||||
}
|
||||
|
||||
#[test]
|
||||
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");
|
||||
}
|
||||
|
||||
#[test]
|
||||
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");
|
||||
}
|
||||
|
||||
#[test]
|
||||
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");
|
||||
}
|
||||
|
||||
#[test]
|
||||
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");
|
||||
}
|
||||
|
||||
|
@ -73,20 +73,20 @@ fn unexpand_first_only_1() {
|
|||
fn unexpand_trailing_space_0() { // evil
|
||||
// Individual spaces before fields starting with non blanks should not be
|
||||
// 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 ");
|
||||
}
|
||||
|
||||
#[test]
|
||||
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 ");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unexpand_spaces_follow_tabs_0() {
|
||||
// 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");
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ fn unexpand_spaces_follow_tabs_1() { // evil
|
|||
// ' \t' -> '\t' // second tabstop (4)
|
||||
// ' ' -> '\t' // third tabstop (5)
|
||||
// ' 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");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue