Skip to content

Commit

Permalink
tests: add apply operations gender_guess test
Browse files Browse the repository at this point in the history
  • Loading branch information
jqnatividad committed Jan 27, 2024
1 parent f345aac commit a3aa413
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions tests/test_apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,61 @@ fn apply_ops_upper() {
assert_eq!(got, expected);
}

#[test]
fn apply_ops_gender_guess() {
let wrk = Workdir::new("apply");
wrk.create(
"data.csv",
vec![
svec!["name"],
svec!["Peter"],
svec!["Michael"],
svec!["Joel"],
svec!["Hussein"],
svec!["Ian"],
svec!["Enrique"],
svec!["Ana"],
svec!["Olivia"],
svec!["Mackenzie"],
svec!["Adair"],
svec!["Aaf"],
svec!["Voldemort"],
svec!["Sami"],
svec!["Minhaj"],
svec!["Abdurrahman"],
svec!["Abbe"],
],
);
let mut cmd = wrk.command("apply");
cmd.arg("operations")
.arg("gender_guess")
.arg("name")
.args(["--new-column", "Gender"])
.arg("data.csv");

let got: Vec<Vec<String>> = wrk.read_stdout(&mut cmd);
let expected = vec![
svec!["name", "Gender"],
svec!["Peter", "Male"],
svec!["Michael", "Male"],
svec!["Joel", "Male"],
svec!["Hussein", "Male"],
svec!["Ian", "Male"],
svec!["Enrique", "Male"],
svec!["Ana", "Female"],
svec!["Olivia", "Female"],
svec!["Mackenzie", "NotSure"],
svec!["Adair", "MayBeMale"],
svec!["Aaf", "MayBeFemale"],
svec!["Voldemort", "NotFound"],
svec!["Sami", "Male"],
svec!["Minhaj", "NotFound"],
svec!["Abdurrahman", "Male"],
svec!["Abbe", "NotSure"],
];
assert_eq!(got, expected);
}

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

0 comments on commit a3aa413

Please sign in to comment.