Skip to content

Commit

Permalink
tests: add fmt tests for --output and --no-final-newline options
Browse files Browse the repository at this point in the history
  • Loading branch information
jqnatividad committed Jan 16, 2024
1 parent 0e3b756 commit 369a926
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/test_fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,39 @@ mnopqr,stuvwx\r
assert_eq!(got, expected.to_string());
}

#[test]
fn fmt_nofinalnewline() {
let (wrk, mut cmd) = setup("fmt_nofinalnewline");
cmd.arg("--no-final-newline");

let got: String = wrk.stdout(&mut cmd);
let expected = r#"h1,h2
abcdef,ghijkl
mnopqr,stuvwx
"ab""cd""ef","gh,ij,kl""#;
assert_eq!(got, expected.to_string());
}

#[test]
fn fmt_output() {
let (wrk, mut cmd) = setup("fmt_output");

let output_file = wrk.path("output.csv").to_string_lossy().to_string();

cmd.args(["--output", &output_file]);

wrk.assert_success(&mut cmd);

let got = wrk.read_to_string(&output_file);

let expected = r#"h1,h2
abcdef,ghijkl
mnopqr,stuvwx
"ab""cd""ef","gh,ij,kl"
"#;
assert_eq!(got, expected);
}

#[test]
fn fmt_quote_always() {
let (wrk, mut cmd) = setup("fmt_quote_always");
Expand Down

0 comments on commit 369a926

Please sign in to comment.