mirror of
https://github.com/sharkdp/fd.git
synced 2024-11-17 17:35:16 +01:00
Use oss_vec fn in internal/mod.rs tests
This commit is contained in:
parent
095bad550f
commit
caad43fe6c
1 changed files with 52 additions and 57 deletions
|
@ -99,79 +99,74 @@ where
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
fn oss(v: &str) -> OsString {
|
fn oss_vec(strs: &[&str]) -> Vec<OsString> {
|
||||||
OsString::from(v)
|
strs.into_iter().map(OsString::from).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Ensure that -exec gets transformed into --exec
|
/// Ensure that -exec gets transformed into --exec
|
||||||
#[test]
|
#[test]
|
||||||
fn normal_exec_substitution() {
|
fn normal_exec_substitution() {
|
||||||
let original = vec![oss("fd"), oss("foo"), oss("-exec"), oss("cmd")];
|
let original = oss_vec(&["fd", "foo", "-exec", "cmd"]);
|
||||||
let expected = vec![oss("fd"), oss("foo"), oss("--exec"), oss("cmd")];
|
let expected = oss_vec(&["fd", "foo", "--exec", "cmd"]);
|
||||||
|
|
||||||
let actual = transform_args_with_exec(original.into_iter());
|
let actual = transform_args_with_exec(original.into_iter());
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Ensure that --exec is not touched
|
/// Ensure that --exec is not touched
|
||||||
#[test]
|
#[test]
|
||||||
fn passthru_of_original_exec() {
|
fn passthru_of_original_exec() {
|
||||||
let original = vec![oss("fd"), oss("foo"), oss("--exec"), oss("cmd")];
|
let original = oss_vec(&["fd", "foo", "--exec", "cmd"]);
|
||||||
let expected = vec![oss("fd"), oss("foo"), oss("--exec"), oss("cmd")];
|
let expected = oss_vec(&["fd", "foo", "--exec", "cmd"]);
|
||||||
|
|
||||||
let actual = transform_args_with_exec(original.into_iter());
|
let actual = transform_args_with_exec(original.into_iter());
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn temp_check_that_exec_context_observed() {
|
fn temp_check_that_exec_context_observed() {
|
||||||
let original = vec![
|
let original = oss_vec(&[
|
||||||
oss("fd"),
|
"fd",
|
||||||
oss("foo"),
|
"foo",
|
||||||
oss("-exec"),
|
"-exec",
|
||||||
oss("cmd"),
|
"cmd",
|
||||||
oss("-exec"),
|
"-exec",
|
||||||
oss("ls"),
|
"ls",
|
||||||
oss(";"),
|
";",
|
||||||
oss("-exec"),
|
"-exec",
|
||||||
oss("rm"),
|
"rm",
|
||||||
oss(";"),
|
";",
|
||||||
oss("--exec"),
|
"--exec",
|
||||||
oss("find"),
|
"find",
|
||||||
oss("-exec"),
|
"-exec",
|
||||||
oss("rm"),
|
"rm",
|
||||||
oss(";"),
|
";",
|
||||||
oss("-x"),
|
"-x",
|
||||||
oss("foo"),
|
"foo",
|
||||||
oss("-exec"),
|
"-exec",
|
||||||
oss("something"),
|
"something",
|
||||||
oss(";"),
|
";",
|
||||||
oss("-exec"),
|
"-exec",
|
||||||
];
|
]);
|
||||||
let expected = vec![
|
let expected = oss_vec(&[
|
||||||
oss("fd"),
|
"fd",
|
||||||
oss("foo"),
|
"foo",
|
||||||
oss("--exec"),
|
"--exec",
|
||||||
oss("cmd"),
|
"cmd",
|
||||||
oss("-exec"),
|
"-exec",
|
||||||
oss("ls"),
|
"ls",
|
||||||
oss(";"),
|
";",
|
||||||
oss("--exec"),
|
"--exec",
|
||||||
oss("rm"),
|
"rm",
|
||||||
oss(";"),
|
";",
|
||||||
oss("--exec"),
|
"--exec",
|
||||||
oss("find"),
|
"find",
|
||||||
oss("-exec"),
|
"-exec",
|
||||||
oss("rm"),
|
"rm",
|
||||||
oss(";"),
|
";",
|
||||||
oss("-x"),
|
"-x",
|
||||||
oss("foo"),
|
"foo",
|
||||||
oss("-exec"),
|
"-exec",
|
||||||
oss("something"),
|
"something",
|
||||||
oss(";"),
|
";",
|
||||||
oss("--exec"),
|
"--exec",
|
||||||
];
|
]);
|
||||||
|
|
||||||
let actual = transform_args_with_exec(original.into_iter());
|
let actual = transform_args_with_exec(original.into_iter());
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue