mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 20:17:45 +00:00
commit
2f17bfc14c
56 changed files with 2006 additions and 217 deletions
|
@ -2,10 +2,17 @@ use crate::common::util::*;
|
|||
|
||||
fn test_helper(file_name: &str, args: &str) {
|
||||
new_ucmd!()
|
||||
.arg(args)
|
||||
.arg(format!("{}.txt", file_name))
|
||||
.args(&args.split(' ').collect::<Vec<&str>>())
|
||||
.succeeds()
|
||||
.stdout_is_fixture(format!("{}.expected", file_name));
|
||||
|
||||
new_ucmd!()
|
||||
.arg(format!("{}.txt", file_name))
|
||||
.arg("--debug")
|
||||
.args(&args.split(' ').collect::<Vec<&str>>())
|
||||
.succeeds()
|
||||
.stdout_is_fixture(format!("{}.expected.debug", file_name));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -29,11 +36,7 @@ fn test_human_numeric_whitespace() {
|
|||
|
||||
#[test]
|
||||
fn test_multiple_decimals_general() {
|
||||
new_ucmd!()
|
||||
.arg("-g")
|
||||
.arg("multiple_decimals_general.txt")
|
||||
.succeeds()
|
||||
.stdout_is("\n\n\n\n\n\n\n\nCARAvan\n-2028789030\n-896689\n-8.90880\n-1\n-.05\n000\n00000001\n1\n1.040000000\n1.444\n1.58590\n8.013\n45\n46.89\n576,446.88800000\n576,446.890\n 4567.\n4567.1\n4567.34\n\t\t\t\t\t\t\t\t\t\t4567..457\n\t\t\t\t37800\n\t\t\t\t\t\t45670.89079.098\n\t\t\t\t\t\t45670.89079.1\n4798908.340000000000\n4798908.45\n4798908.8909800\n");
|
||||
test_helper("multiple_decimals_general", "-g")
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -209,13 +212,7 @@ fn test_non_printing_chars() {
|
|||
|
||||
#[test]
|
||||
fn test_exponents_positive_general_fixed() {
|
||||
for exponents_positive_general_param in vec!["-g"] {
|
||||
new_ucmd!()
|
||||
.pipe_in("100E6\n\n50e10\n+100000\n\n10000K78\n10E\n\n\n1000EDKLD\n\n\n100E6\n\n50e10\n+100000\n\n")
|
||||
.arg(exponents_positive_general_param)
|
||||
.succeeds()
|
||||
.stdout_only("\n\n\n\n\n\n\n\n10000K78\n1000EDKLD\n10E\n+100000\n+100000\n100E6\n100E6\n50e10\n50e10\n");
|
||||
}
|
||||
test_helper("exponents_general", "-g");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -334,62 +331,32 @@ fn test_numeric_unique_ints2() {
|
|||
|
||||
#[test]
|
||||
fn test_keys_open_ended() {
|
||||
let input = "aa bb cc\ndd aa ff\ngg aa cc\n";
|
||||
new_ucmd!()
|
||||
.args(&["-k", "2.2"])
|
||||
.pipe_in(input)
|
||||
.succeeds()
|
||||
.stdout_only("gg aa cc\ndd aa ff\naa bb cc\n");
|
||||
test_helper("keys_open_ended", "-k 2.3");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_keys_closed_range() {
|
||||
let input = "aa bb cc\ndd aa ff\ngg aa cc\n";
|
||||
new_ucmd!()
|
||||
.args(&["-k", "2.2,2.2"])
|
||||
.pipe_in(input)
|
||||
.succeeds()
|
||||
.stdout_only("dd aa ff\ngg aa cc\naa bb cc\n");
|
||||
test_helper("keys_closed_range", "-k 2.2,2.2");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_keys_multiple_ranges() {
|
||||
let input = "aa bb cc\ndd aa ff\ngg aa cc\n";
|
||||
new_ucmd!()
|
||||
.args(&["-k", "2,2", "-k", "3,3"])
|
||||
.pipe_in(input)
|
||||
.succeeds()
|
||||
.stdout_only("gg aa cc\ndd aa ff\naa bb cc\n");
|
||||
test_helper("keys_multiple_ranges", "-k 2,2 -k 3,3");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_keys_no_field_match() {
|
||||
let input = "aa aa aa aa\naa bb cc\ndd aa ff\n";
|
||||
new_ucmd!()
|
||||
.args(&["-k", "4,4"])
|
||||
.pipe_in(input)
|
||||
.succeeds()
|
||||
.stdout_only("aa bb cc\ndd aa ff\naa aa aa aa\n");
|
||||
test_helper("keys_no_field_match", "-k 4,4");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_keys_no_char_match() {
|
||||
let input = "aaa\nba\nc\n";
|
||||
new_ucmd!()
|
||||
.args(&["-k", "1.2"])
|
||||
.pipe_in(input)
|
||||
.succeeds()
|
||||
.stdout_only("c\nba\naaa\n");
|
||||
test_helper("keys_no_char_match", "-k 1.2");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_keys_custom_separator() {
|
||||
let input = "aaxbbxcc\nddxaaxff\nggxaaxcc\n";
|
||||
new_ucmd!()
|
||||
.args(&["-k", "2.2,2.2", "-t", "x"])
|
||||
.pipe_in(input)
|
||||
.succeeds()
|
||||
.stdout_only("ddxaaxff\nggxaaxcc\naaxbbxcc\n");
|
||||
test_helper("keys_custom_separator", "-k 2.2,2.2 -t x");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -416,6 +383,13 @@ fn test_keys_invalid_field_zero() {
|
|||
.stderr_only("sort: error: field index was 0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_keys_invalid_char_zero() {
|
||||
new_ucmd!().args(&["-k", "1.0"]).fails().stderr_only(
|
||||
"sort: error: invalid character index 0 in `1.0` for the start position of a field",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_keys_with_options() {
|
||||
let input = "aa 3 cc\ndd 1 ff\ngg 2 cc\n";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue