1 use super::make_command_line;
2 use crate::ffi::{OsStr, OsString};
5 fn test_make_command_line() {
6 fn test_wrapper(prog: &str, args: &[&str], force_quotes: bool) -> String {
7 let command_line = &make_command_line(
9 &args.iter().map(|a| OsString::from(a)).collect::<Vec<OsString>>(),
13 String::from_utf16(command_line).unwrap()
16 assert_eq!(test_wrapper("prog", &["aaa", "bbb", "ccc"], false), "\"prog\" aaa bbb ccc");
19 test_wrapper("C:\\Program Files\\blah\\blah.exe", &["aaa"], false),
20 "\"C:\\Program Files\\blah\\blah.exe\" aaa"
23 test_wrapper("C:\\Program Files\\blah\\blah.exe", &["aaa", "v*"], false),
24 "\"C:\\Program Files\\blah\\blah.exe\" aaa v*"
27 test_wrapper("C:\\Program Files\\blah\\blah.exe", &["aaa", "v*"], true),
28 "\"C:\\Program Files\\blah\\blah.exe\" \"aaa\" \"v*\""
31 test_wrapper("C:\\Program Files\\test", &["aa\"bb"], false),
32 "\"C:\\Program Files\\test\" aa\\\"bb"
34 assert_eq!(test_wrapper("echo", &["a b c"], false), "\"echo\" \"a b c\"");
36 test_wrapper("echo", &["\" \\\" \\", "\\"], false),
37 "\"echo\" \"\\\" \\\\\\\" \\\\\" \\"
40 test_wrapper("\u{03c0}\u{042f}\u{97f3}\u{00e6}\u{221e}", &[], false),
41 "\"\u{03c0}\u{042f}\u{97f3}\u{00e6}\u{221e}\""