Merge pull request #4753 from cakebaker/fmt_cleanup_tests

fmt: cleanup tests
This commit is contained in:
Sylvestre Ledru 2023-04-20 17:55:55 +02:00 committed by GitHub
commit ab22f49feb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,47 +7,39 @@ fn test_invalid_arg() {
#[test] #[test]
fn test_fmt() { fn test_fmt() {
let result = new_ucmd!().arg("one-word-per-line.txt").run(); new_ucmd!()
//.stdout_is_fixture("call_graph.expected"); .arg("one-word-per-line.txt")
assert_eq!( .succeeds()
result.stdout_str().trim(), .stdout_is("this is a file with one word per line\n");
"this is a file with one word per line"
);
} }
#[test] #[test]
fn test_fmt_q() { fn test_fmt_quick() {
let result = new_ucmd!().arg("-q").arg("one-word-per-line.txt").run(); for param in ["-q", "--quick"] {
//.stdout_is_fixture("call_graph.expected"); new_ucmd!()
assert_eq!( .args(&["one-word-per-line.txt", param])
result.stdout_str().trim(), .succeeds()
"this is a file with one word per line" .stdout_is("this is a file with one word per line\n");
); }
} }
#[test] #[test]
fn test_fmt_w_too_big() { fn test_fmt_width() {
let result = new_ucmd!() for param in ["-w", "--width"] {
.arg("-w") new_ucmd!()
.arg("2501") .args(&["one-word-per-line.txt", param, "10"])
.arg("one-word-per-line.txt") .succeeds()
.run(); .stdout_is("this is\na file\nwith one\nword per\nline\n");
//.stdout_is_fixture("call_graph.expected"); }
assert_eq!(
result.stderr_str().trim(),
"fmt: invalid width: '2501': Numerical result out of range"
);
} }
#[test] #[test]
fn test_fmt_w() { fn test_fmt_width_too_big() {
let result = new_ucmd!() for param in ["-w", "--width"] {
.arg("-w") new_ucmd!()
.arg("10") .args(&["one-word-per-line.txt", param, "2501"])
.arg("one-word-per-line.txt") .fails()
.run(); .code_is(1)
//.stdout_is_fixture("call_graph.expected"); .stderr_is("fmt: invalid width: '2501': Numerical result out of range\n");
assert_eq!( }
result.stdout_str().trim(),
"this is\na file\nwith one\nword per\nline"
);
} }