@@ -5,9 +5,9 @@ fn chk(string: &str, parts: &[&str]) {
5
5
let mut wide: Vec < u16 > = OsString :: from ( string) . encode_wide ( ) . collect ( ) ;
6
6
wide. push ( 0 ) ;
7
7
let parsed =
8
- unsafe { parse_lp_cmd_line ( wide. as_ptr ( ) as * const u16 , || OsString :: from ( "TEST.EXE" ) ) } ;
8
+ unsafe { parse_lp_cmd_line ( WStrUnits :: new ( wide. as_ptr ( ) ) , || OsString :: from ( "TEST.EXE" ) ) } ;
9
9
let expected: Vec < OsString > = parts. iter ( ) . map ( |k| OsString :: from ( k) ) . collect ( ) ;
10
- assert_eq ! ( parsed. as_slice( ) , expected. as_slice( ) ) ;
10
+ assert_eq ! ( parsed. as_slice( ) , expected. as_slice( ) , "{:?}" , string ) ;
11
11
}
12
12
13
13
#[ test]
@@ -27,35 +27,65 @@ fn single_words() {
27
27
#[ test]
28
28
fn official_examples ( ) {
29
29
chk ( r#"EXE "abc" d e"# , & [ "EXE" , "abc" , "d" , "e" ] ) ;
30
- chk ( r#"EXE a\\\b d"e f"g h"# , & [ "EXE" , r# "a\\\b"# , "de fg" , "h" ] ) ;
30
+ chk ( r#"EXE a\\\b d"e f"g h"# , & [ "EXE" , r"a\\\b" , "de fg" , "h" ] ) ;
31
31
chk ( r#"EXE a\\\"b c d"# , & [ "EXE" , r#"a\"b"# , "c" , "d" ] ) ;
32
- chk ( r#"EXE a\\\\"b c" d e"# , & [ "EXE" , r# "a\\b c"# , "d" , "e" ] ) ;
32
+ chk ( r#"EXE a\\\\"b c" d e"# , & [ "EXE" , r"a\\b c" , "d" , "e" ] ) ;
33
33
}
34
34
35
35
#[ test]
36
36
fn whitespace_behavior ( ) {
37
- chk ( r# " test"# , & [ "" , "test" ] ) ;
38
- chk ( r# " test"# , & [ "" , "test" ] ) ;
39
- chk ( r# " test test2"# , & [ "" , "test" , "test2" ] ) ;
40
- chk ( r# " test test2"# , & [ "" , "test" , "test2" ] ) ;
41
- chk ( r# "test test2 "# , & [ "test" , "test2" ] ) ;
42
- chk ( r# "test test2 "# , & [ "test" , "test2" ] ) ;
43
- chk ( r# "test "# , & [ "test" ] ) ;
37
+ chk ( " test" , & [ "" , "test" ] ) ;
38
+ chk ( " test" , & [ "" , "test" ] ) ;
39
+ chk ( " test test2" , & [ "" , "test" , "test2" ] ) ;
40
+ chk ( " test test2" , & [ "" , "test" , "test2" ] ) ;
41
+ chk ( "test test2 " , & [ "test" , "test2" ] ) ;
42
+ chk ( "test test2 " , & [ "test" , "test2" ] ) ;
43
+ chk ( "test " , & [ "test" ] ) ;
44
44
}
45
45
46
46
#[ test]
47
47
fn genius_quotes ( ) {
48
48
chk ( r#"EXE "" """# , & [ "EXE" , "" , "" ] ) ;
49
- chk ( r#"EXE "" """"# , & [ "EXE" , "" , " \" " ] ) ;
49
+ chk ( r#"EXE "" """"# , & [ "EXE" , "" , r#"""# ] ) ;
50
50
chk (
51
51
r#"EXE "this is """all""" in the same argument""# ,
52
- & [ "EXE" , "this is \ " all\ " in the same argument" ] ,
52
+ & [ "EXE" , r# "this is "all" in the same argument"# ] ,
53
53
) ;
54
- chk ( r#"EXE "a"""# , & [ "EXE" , "a \" " ] ) ;
55
- chk ( r#"EXE "a"" a"# , & [ "EXE" , "a \" " , "a" ] ) ;
54
+ chk ( r#"EXE "a"""# , & [ "EXE" , r#"a""# ] ) ;
55
+ chk ( r#"EXE "a"" a"# , & [ "EXE" , r#"a" a"# ] ) ;
56
56
// quotes cannot be escaped in command names
57
57
chk ( r#""EXE" check"# , & [ "EXE" , "check" ] ) ;
58
58
chk ( r#""EXE check""# , & [ "EXE check" ] ) ;
59
- chk ( r#""EXE """for""" check"# , & [ "EXE " , r#"for""# , "check" ] ) ;
60
- chk ( r#""EXE \"for\" check"# , & [ r#"EXE \"# , r#"for""# , "check" ] ) ;
59
+ chk ( r#""EXE """for""" check"# , & [ "EXE for check" ] ) ;
60
+ chk ( r#""EXE \"for\" check"# , & [ r"EXE \for\ check" ] ) ;
61
+ chk ( r#""EXE \" for \" check"# , & [ r"EXE \" , "for" , r#"""# , "check" ] ) ;
62
+ chk ( r#"E"X"E test"# , & [ "EXE" , "test" ] ) ;
63
+ chk ( r#"EX""E test"# , & [ "EXE" , "test" ] ) ;
64
+ }
65
+
66
+ // from https://daviddeley.com/autohotkey/parameters/parameters.htm#WINCRULESEX
67
+ #[ test]
68
+ fn post_2008 ( ) {
69
+ chk ( "EXE CallMeIshmael" , & [ "EXE" , "CallMeIshmael" ] ) ;
70
+ chk ( r#"EXE "Call Me Ishmael""# , & [ "EXE" , "Call Me Ishmael" ] ) ;
71
+ chk ( r#"EXE Cal"l Me I"shmael"# , & [ "EXE" , "Call Me Ishmael" ] ) ;
72
+ chk ( r#"EXE CallMe\"Ishmael"# , & [ "EXE" , r#"CallMe"Ishmael"# ] ) ;
73
+ chk ( r#"EXE "CallMe\"Ishmael""# , & [ "EXE" , r#"CallMe"Ishmael"# ] ) ;
74
+ chk ( r#"EXE "Call Me Ishmael\\""# , & [ "EXE" , r"Call Me Ishmael\" ] ) ;
75
+ chk ( r#"EXE "CallMe\\\"Ishmael""# , & [ "EXE" , r#"CallMe\"Ishmael"# ] ) ;
76
+ chk ( r#"EXE a\\\b"# , & [ "EXE" , r"a\\\b" ] ) ;
77
+ chk ( r#"EXE "a\\\b""# , & [ "EXE" , r"a\\\b" ] ) ;
78
+ chk ( r#"EXE "\"Call Me Ishmael\"""# , & [ "EXE" , r#""Call Me Ishmael""# ] ) ;
79
+ chk ( r#"EXE "C:\TEST A\\""# , & [ "EXE" , r"C:\TEST A\" ] ) ;
80
+ chk ( r#"EXE "\"C:\TEST A\\\"""# , & [ "EXE" , r#""C:\TEST A\""# ] ) ;
81
+ chk ( r#"EXE "a b c" d e"# , & [ "EXE" , "a b c" , "d" , "e" ] ) ;
82
+ chk ( r#"EXE "ab\"c" "\\" d"# , & [ "EXE" , r#"ab"c"# , r"\" , "d" ] ) ;
83
+ chk ( r#"EXE a\\\b d"e f"g h"# , & [ "EXE" , r"a\\\b" , "de fg" , "h" ] ) ;
84
+ chk ( r#"EXE a\\\"b c d"# , & [ "EXE" , r#"a\"b"# , "c" , "d" ] ) ;
85
+ chk ( r#"EXE a\\\\"b c" d e"# , & [ "EXE" , r"a\\b c" , "d" , "e" ] ) ;
86
+ // Double Double Quotes
87
+ chk ( r#"EXE "a b c"""# , & [ "EXE" , r#"a b c""# ] ) ;
88
+ chk ( r#"EXE """CallMeIshmael""" b c"# , & [ "EXE" , r#""CallMeIshmael""# , "b" , "c" ] ) ;
89
+ chk ( r#"EXE """Call Me Ishmael""""# , & [ "EXE" , r#""Call Me Ishmael""# ] ) ;
90
+ chk ( r#"EXE """"Call Me Ishmael"" b c"# , & [ "EXE" , r#""Call"# , "Me" , "Ishmael" , "b" , "c" ] ) ;
61
91
}
0 commit comments