From 5e4eb37195fdbf66c626f63eb641b6af60a82526 Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Thu, 9 Nov 2023 07:39:27 -0500 Subject: [PATCH] `cat`: add test for `--flexible` option --- tests/test_cat.rs | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/test_cat.rs b/tests/test_cat.rs index b450d883a..a705625a5 100644 --- a/tests/test_cat.rs +++ b/tests/test_cat.rs @@ -119,6 +119,58 @@ fn cat_rowskey() { assert_eq!(got, expected); } +#[test] +fn cat_rows_flexible() { + let wrk = Workdir::new("cat_rows_flexible"); + wrk.create( + "in1.csv", + vec![ + svec!["a", "b", "c"], + svec!["1", "2", "3"], + svec!["2", "3", "4"], + ], + ); + + wrk.create( + "in2.csv", + vec![ + svec!["a", "b", "c"], + svec!["3", "1", "2"], + svec!["4", "2", "3"], + ], + ); + + wrk.create( + "in3.csv", + vec![ + svec!["a", "b", "c", "d"], + svec!["1", "2", "4", "3"], + svec!["2", "3", "5", "4"], + svec!["z", "y", "w", "x"], + ], + ); + + let mut cmd = wrk.command("cat"); + cmd.arg("rows") + .arg("--flexible") + .arg("in1.csv") + .arg("in2.csv") + .arg("in3.csv"); + + let got: Vec> = wrk.read_stdout(&mut cmd); + let expected = vec![ + svec!["a", "b", "c"], + svec!["1", "2", "3"], + svec!["2", "3", "4"], + svec!["3", "1", "2"], + svec!["4", "2", "3"], + svec!["1", "2", "4", "3"], + svec!["2", "3", "5", "4"], + svec!["z", "y", "w", "x"], + ]; + assert_eq!(got, expected); +} + #[test] fn cat_rowskey_grouping() { let wrk = Workdir::new("cat_rowskey_grouping");