From 3f718b8335e29e54bf01349f66d837b268e21988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20M=2E=20Bezerra?= Date: Tue, 5 Oct 2021 22:21:11 -0300 Subject: [PATCH] Simplify tests by making gen_args more generic --- src/cli.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 0865124..0cde41f 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -154,9 +154,9 @@ mod tests { use super::*; - fn gen_args(text: &str) -> Vec { + fn gen_args>(text: &str) -> Vec { let args = text.split_whitespace(); - args.map(OsString::from).collect() + args.map(OsString::from).map(T::from).collect() } fn test_cli(args: &str) -> crate::Result { @@ -172,19 +172,19 @@ mod tests { assert_eq!(test_cli("--version").unwrap().flags, oof::Flags::default()); assert_eq!( test_cli("decompress foo.zip bar.zip").unwrap().command, - Command::Decompress { files: vec!["foo.zip".into(), "bar.zip".into()], output_folder: None } + Command::Decompress { files: gen_args("foo.zip bar.zip"), output_folder: None } ); assert_eq!( test_cli("d foo.zip bar.zip").unwrap().command, - Command::Decompress { files: vec!["foo.zip".into(), "bar.zip".into()], output_folder: None } + Command::Decompress { files: gen_args("foo.zip bar.zip"), output_folder: None } ); assert_eq!( test_cli("compress foo bar baz.zip").unwrap().command, - Command::Compress { files: vec!["foo".into(), "bar".into()], output_path: "baz.zip".into() } + Command::Compress { files: gen_args("foo bar"), output_path: "baz.zip".into() } ); assert_eq!( test_cli("c foo bar baz.zip").unwrap().command, - Command::Compress { files: vec!["foo".into(), "bar".into()], output_path: "baz.zip".into() } + Command::Compress { files: gen_args("foo bar"), output_path: "baz.zip".into() } ); assert_eq!(test_cli("compress").unwrap_err(), Error::MissingArgumentsForCompression); // assert_eq!(test_cli("decompress").unwrap_err(), Error::MissingArgumentsForCompression); // TODO