@@ -5,9 +5,9 @@ fn chk(string: &str, parts: &[&str]) {
55 let mut wide: Vec < u16 > = OsString :: from ( string) . encode_wide ( ) . collect ( ) ;
66 wide. push ( 0 ) ;
77 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" ) ) } ;
99 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 ) ;
1111}
1212
1313#[ test]
@@ -27,35 +27,65 @@ fn single_words() {
2727#[ test]
2828fn official_examples ( ) {
2929 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" ] ) ;
3131 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" ] ) ;
3333}
3434
3535#[ test]
3636fn 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" ] ) ;
4444}
4545
4646#[ test]
4747fn genius_quotes ( ) {
4848 chk ( r#"EXE "" """# , & [ "EXE" , "" , "" ] ) ;
49- chk ( r#"EXE "" """"# , & [ "EXE" , "" , " \" " ] ) ;
49+ chk ( r#"EXE "" """"# , & [ "EXE" , "" , r#"""# ] ) ;
5050 chk (
5151 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"# ] ,
5353 ) ;
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"# ] ) ;
5656 // quotes cannot be escaped in command names
5757 chk ( r#""EXE" check"# , & [ "EXE" , "check" ] ) ;
5858 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" ] ) ;
6191}
0 commit comments