mirror of
https://github.com/uutils/coreutils
synced 2024-12-15 07:42:48 +00:00
103 lines
2.6 KiB
Rust
103 lines
2.6 KiB
Rust
// This file is part of the uutils coreutils package.
|
|
//
|
|
// For the full copyright and license information, please view the LICENSE
|
|
// file that was distributed with this source code.
|
|
use crate::common::util::TestScenario;
|
|
|
|
#[test]
|
|
fn test_invalid_arg() {
|
|
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
|
|
}
|
|
|
|
#[test]
|
|
fn test_fmt() {
|
|
new_ucmd!()
|
|
.arg("one-word-per-line.txt")
|
|
.succeeds()
|
|
.stdout_is("this is a file with one word per line\n");
|
|
}
|
|
|
|
#[test]
|
|
fn test_fmt_quick() {
|
|
for param in ["-q", "--quick"] {
|
|
new_ucmd!()
|
|
.args(&["one-word-per-line.txt", param])
|
|
.succeeds()
|
|
.stdout_is("this is a file with one word per line\n");
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn test_fmt_width() {
|
|
for param in ["-w", "--width"] {
|
|
new_ucmd!()
|
|
.args(&["one-word-per-line.txt", param, "10"])
|
|
.succeeds()
|
|
.stdout_is("this is\na file\nwith one\nword per\nline\n");
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn test_fmt_width_too_big() {
|
|
for param in ["-w", "--width"] {
|
|
new_ucmd!()
|
|
.args(&["one-word-per-line.txt", param, "2501"])
|
|
.fails()
|
|
.code_is(1)
|
|
.stderr_is("fmt: invalid width: '2501': Numerical result out of range\n");
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn test_fmt_invalid_width() {
|
|
for param in ["-w", "--width"] {
|
|
new_ucmd!()
|
|
.args(&["one-word-per-line.txt", param, "invalid"])
|
|
.fails()
|
|
.code_is(1)
|
|
.stderr_contains("invalid value 'invalid'");
|
|
}
|
|
}
|
|
|
|
#[ignore]
|
|
#[test]
|
|
fn test_fmt_goal() {
|
|
for param in ["-g", "--goal"] {
|
|
new_ucmd!()
|
|
.args(&["one-word-per-line.txt", param, "7"])
|
|
.succeeds()
|
|
.stdout_is("this is a\nfile with one\nword per line\n");
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn test_fmt_goal_too_big() {
|
|
for param in ["-g", "--goal"] {
|
|
new_ucmd!()
|
|
.args(&["one-word-per-line.txt", "--width=75", param, "76"])
|
|
.fails()
|
|
.code_is(1)
|
|
.stderr_is("fmt: GOAL cannot be greater than WIDTH.\n");
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn test_fmt_invalid_goal() {
|
|
for param in ["-g", "--goal"] {
|
|
new_ucmd!()
|
|
.args(&["one-word-per-line.txt", param, "invalid"])
|
|
.fails()
|
|
.code_is(1)
|
|
.stderr_contains("invalid value 'invalid'");
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn test_fmt_set_goal_not_contain_width() {
|
|
for param in ["-g", "--goal"] {
|
|
new_ucmd!()
|
|
.args(&["one-word-per-line.txt", param, "74"])
|
|
.succeeds()
|
|
.stdout_is("this is a file with one word per line\n");
|
|
}
|
|
}
|