Skip to content

Commit

Permalink
test: add enum and apply calcconv test for #1458
Browse files Browse the repository at this point in the history
it seems the problem is also not present in debug/devt mode, and only shows itself in release mode...

see #1458
  • Loading branch information
jqnatividad committed Dec 8, 2023
1 parent c951462 commit 3342cb4
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/test_apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,58 @@ fn apply_calcconv_units() {
assert_eq!(got, expected);
}

#[test]
fn enum_apply_calconv_issue1458() {
let wrk = Workdir::new("enum_apply_calconv_issue1458");
wrk.create(
"data.csv",
vec![
svec!["FirstName", "MI", "LastName",],
svec!["Adam", "B", "Case"],
svec!["Derek", "E", "Foster"],
svec!["Gordon", "H", "Irvin"],
svec!["Jack", "K", "Lynch"],
],
);

// qsv enum file.csv | qsv apply calcconv --formatstr '{index} * {index}' -c result

let mut cmd = wrk.command("enum");
cmd.arg("data.csv");

let got: Vec<Vec<String>> = wrk.read_stdout(&mut cmd);
let expected = vec![
svec!["FirstName", "MI", "LastName", "index"],
svec!["Adam", "B", "Case", "0"],
svec!["Derek", "E", "Foster", "1"],
svec!["Gordon", "H", "Irvin", "2"],
svec!["Jack", "K", "Lynch", "3"],
];

assert_eq!(got, expected);

wrk.create("enum.csv", got);

let mut cmd2 = wrk.command("apply");
cmd2.arg("calcconv")
.arg("--formatstr")
.arg("{index} * {index}")
.arg("-c")
.arg("result")
.arg("enum.csv");

let got2: Vec<Vec<String>> = wrk.read_stdout(&mut cmd2);
let expected2 = vec![
svec!["FirstName", "MI", "LastName", "index", "result"],
svec!["Adam", "B", "Case", "0", "0"],
svec!["Derek", "E", "Foster", "1", "1"],
svec!["Gordon", "H", "Irvin", "2", "4"],
svec!["Jack", "K", "Lynch", "3", "9"],
];

assert_eq!(got2, expected2);
}

#[test]
fn apply_ops_empty_shortcircuit() {
let wrk = Workdir::new("apply");
Expand Down

0 comments on commit 3342cb4

Please sign in to comment.