Skip to content

Commit ad85ee2

Browse files
Add test.
1 parent a03491e commit ad85ee2

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

src/parser/command_line.rs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,4 +458,58 @@ mod test {
458458
]
459459
);
460460
}
461+
462+
#[test]
463+
fn test_auto_regex() {
464+
let command_line_args = CommandLineArgs {
465+
command_and_initial_arguments: [
466+
"echo", "got", "arg1={1}", "arg2={2}", ":::", "foo", "bar", ":::", "baz", "qux",
467+
]
468+
.into_iter()
469+
.map_into()
470+
.collect(),
471+
..Default::default()
472+
};
473+
474+
let parser = CommandLineArgsParser::new(
475+
&command_line_args,
476+
&RegexProcessor::new(&command_line_args).unwrap(),
477+
);
478+
479+
let result = collect_into_vec(parser);
480+
481+
assert_eq!(
482+
result,
483+
vec![
484+
OwnedCommandAndArgs {
485+
command_path: PathBuf::from("echo"),
486+
args: ["got", "arg1=foo", "arg2=baz"]
487+
.into_iter()
488+
.map_into()
489+
.collect(),
490+
},
491+
OwnedCommandAndArgs {
492+
command_path: PathBuf::from("echo"),
493+
args: ["got", "arg1=foo", "arg2=qux"]
494+
.into_iter()
495+
.map_into()
496+
.collect(),
497+
},
498+
OwnedCommandAndArgs {
499+
command_path: PathBuf::from("echo"),
500+
args: ["got", "arg1=bar", "arg2=baz"]
501+
.into_iter()
502+
.map_into()
503+
.collect(),
504+
},
505+
OwnedCommandAndArgs {
506+
command_path: PathBuf::from("echo"),
507+
args: ["got", "arg1=bar", "arg2=qux"]
508+
.into_iter()
509+
.map_into()
510+
.collect(),
511+
},
512+
]
513+
);
514+
}
461515
}

0 commit comments

Comments
 (0)