diff --git a/Cargo.lock b/Cargo.lock index 20093c7..89bbc36 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -116,9 +116,9 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2584f639eb95fea8c798496315b297cf81b9b58b6d30ab066a75455333cf4b12" +checksum = "52fb27eab85b17fbb9f6fd667089e07d6a2eb8743d02639ee7f6a7a7729c9c94" dependencies = [ "cfg-if", "crossbeam-utils", @@ -129,9 +129,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7e9d99fa91428effe99c5c6d4634cdeba32b8cf784fc428a2a687f61a952c49" +checksum = "4feb231f0d4d6af81aed15928e58ecf5816aa62a2393e2c82f46973e92a9a278" dependencies = [ "autocfg", "cfg-if", @@ -656,9 +656,9 @@ checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" [[package]] name = "unicode-xid" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "unicode_categories" diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 05d8285..48f193b 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -1,5 +1,5 @@ use crate::findings::Findings; -use crate::formats::{Format, Shell}; +use crate::formats::{Format, Shell, PowerShell}; use crate::inspectors::{mime_extension_lookup, BUF_SIZE}; use crate::mime_db::MimeDb; use crate::string_type::String; @@ -336,22 +336,33 @@ fn outputs_move_commands() { mime: IMAGE_JPEG, })]; - let mut cursor = std::io::Cursor::new(Vec::new()); - let mut contents = std::string::String::new(); + for format in ["Shell", "PowerShell"].iter() { + let mut cursor = std::io::Cursor::new(Vec::new()); + let mut contents = std::string::String::new(); - Shell::new() - .write_all(&mut cursor, &entries) - .expect("Failed to write to cursor"); - cursor.set_position(0); - cursor - .read_to_string(&mut contents) - .expect("Failed to read from cursor to string"); + match *format { + "Shell" => Shell::new() + .write_all(&mut cursor, &entries) + .expect("Failed to write to cursor"), + "PowerShell" => PowerShell::new() + .write_all(&mut cursor, &entries) + .expect("Failed to write to cursor"), + _ => unreachable!() + } + + cursor.set_position(0); + cursor + .read_to_string(&mut contents) + .expect("Failed to read from cursor to string"); + + // the output should contain a command like "mv -i misnamed_file.png misnamed_file.jpg" + assert!( + contents.contains("misnamed_file.jpg"), + "{} output doesn't contain move command!", + format + ) + } - // the output should contain a command like "mv -i misnamed_file.png misnamed_file.jpg" - assert!( - contents.contains("misnamed_file.jpg"), - "Output doesn't contain move command!" - ) } #[test]