]> git.lizzy.rs Git - rust.git/blob - library/std/src/sys/windows/process/tests.rs
Merge commit 'd556c56f792756dd7cfec742b9f2e07612dc10f4' into sync_cg_clif-2021-02-01
[rust.git] / library / std / src / sys / windows / process / tests.rs
1 use super::make_command_line;
2 use crate::ffi::{OsStr, OsString};
3
4 #[test]
5 fn test_make_command_line() {
6     fn test_wrapper(prog: &str, args: &[&str]) -> String {
7         let command_line = &make_command_line(
8             OsStr::new(prog),
9             &args.iter().map(|a| OsString::from(a)).collect::<Vec<OsString>>(),
10         )
11         .unwrap();
12         String::from_utf16(command_line).unwrap()
13     }
14
15     assert_eq!(test_wrapper("prog", &["aaa", "bbb", "ccc"]), "\"prog\" aaa bbb ccc");
16
17     assert_eq!(
18         test_wrapper("C:\\Program Files\\blah\\blah.exe", &["aaa"]),
19         "\"C:\\Program Files\\blah\\blah.exe\" aaa"
20     );
21     assert_eq!(
22         test_wrapper("C:\\Program Files\\test", &["aa\"bb"]),
23         "\"C:\\Program Files\\test\" aa\\\"bb"
24     );
25     assert_eq!(test_wrapper("echo", &["a b c"]), "\"echo\" \"a b c\"");
26     assert_eq!(test_wrapper("echo", &["\" \\\" \\", "\\"]), "\"echo\" \"\\\" \\\\\\\" \\\\\" \\");
27     assert_eq!(
28         test_wrapper("\u{03c0}\u{042f}\u{97f3}\u{00e6}\u{221e}", &[]),
29         "\"\u{03c0}\u{042f}\u{97f3}\u{00e6}\u{221e}\""
30     );
31 }