diff --git a/tests/by-util/test_fmt.rs b/tests/by-util/test_fmt.rs index 3e9aadd1b..3c5c37cc7 100644 --- a/tests/by-util/test_fmt.rs +++ b/tests/by-util/test_fmt.rs @@ -185,3 +185,74 @@ fn test_fmt_set_goal_not_contain_width() { .stdout_is("this is a file with one word per line\n"); } } + +#[test] +fn split_does_not_reflow() { + for arg in ["-s", "-ss", "--split-only"] { + new_ucmd!() + .arg("one-word-per-line.txt") + .arg(arg) + .succeeds() + .stdout_is_fixture("one-word-per-line.txt"); + } +} + +#[test] +fn prefix_minus() { + for prefix_args in [ + vec!["-p-"], + vec!["-p", "-"], + vec!["--prefix=-"], + vec!["--prefix", "-"], + vec!["--pref=-"], + vec!["--pref", "-"], + // Test self-overriding: + vec!["--prefix==", "--prefix=-"], + ] { + new_ucmd!() + .args(&prefix_args) + .arg("prefixed-one-word-per-line.txt") + .succeeds() + .stdout_is_fixture("prefixed-one-word-per-line_p-.txt"); + } +} + +#[test] +fn prefix_equal() { + for prefix_args in [ + // FIXME: #6353 vec!["-p="], + vec!["-p", "="], + vec!["--prefix=="], + vec!["--prefix", "="], + vec!["--pref=="], + vec!["--pref", "="], + // Test self-overriding: + vec!["--prefix=-", "--prefix=="], + ] { + new_ucmd!() + .args(&prefix_args) + .arg("prefixed-one-word-per-line.txt") + .succeeds() + .stdout_is_fixture("prefixed-one-word-per-line_p=.txt"); + } +} + +#[test] +fn prefix_equal_skip_prefix_equal_two() { + for prefix_args in [ + // FIXME: #6353 vec!["--prefix==", "-P=2"], + vec!["--prefix==", "-P", "=2"], + vec!["--prefix==", "--skip-prefix==2"], + vec!["--prefix==", "--skip-prefix", "=2"], + vec!["--prefix==", "--skip-pref==2"], + vec!["--prefix==", "--skip-pref", "=2"], + // Test self-overriding: + vec!["--prefix==", "--skip-pref", "asdf", "-P", "=2"], + ] { + new_ucmd!() + .args(&prefix_args) + .arg("prefixed-one-word-per-line.txt") + .succeeds() + .stdout_is_fixture("prefixed-one-word-per-line_p=_P=2.txt"); + } +} diff --git a/tests/fixtures/fmt/prefixed-one-word-per-line.txt b/tests/fixtures/fmt/prefixed-one-word-per-line.txt new file mode 100644 index 000000000..afb9aeec0 --- /dev/null +++ b/tests/fixtures/fmt/prefixed-one-word-per-line.txt @@ -0,0 +1,19 @@ +- this +- is +- a +- file +- with +- one +- word +- per +- line + +=1this +=1is +=1a +=2file +=2with +=2one +=3word +=3per +=3line diff --git a/tests/fixtures/fmt/prefixed-one-word-per-line_p-.txt b/tests/fixtures/fmt/prefixed-one-word-per-line_p-.txt new file mode 100644 index 000000000..4d1073550 --- /dev/null +++ b/tests/fixtures/fmt/prefixed-one-word-per-line_p-.txt @@ -0,0 +1,11 @@ +- this is a file with one word per line + +=1this +=1is +=1a +=2file +=2with +=2one +=3word +=3per +=3line diff --git a/tests/fixtures/fmt/prefixed-one-word-per-line_p=.txt b/tests/fixtures/fmt/prefixed-one-word-per-line_p=.txt new file mode 100644 index 000000000..488cf86de --- /dev/null +++ b/tests/fixtures/fmt/prefixed-one-word-per-line_p=.txt @@ -0,0 +1,11 @@ +- this +- is +- a +- file +- with +- one +- word +- per +- line + +=1this 1is 1a 2file 2with 2one 3word 3per 3line diff --git a/tests/fixtures/fmt/prefixed-one-word-per-line_p=_P=2.txt b/tests/fixtures/fmt/prefixed-one-word-per-line_p=_P=2.txt new file mode 100644 index 000000000..19e951096 --- /dev/null +++ b/tests/fixtures/fmt/prefixed-one-word-per-line_p=_P=2.txt @@ -0,0 +1,15 @@ +- this +- is +- a +- file +- with +- one +- word +- per +- line + +=1this 1is 1a +=2file +=2with +=2one +=3word 3per 3line