@@ -909,7 +909,7 @@ Options:
909909 -c, --brûlée brûlée quite long description
910910 -k, --kiwi€ kiwi description
911911 -o, --orange‹ orange description
912- -r, --raspberry-but-making-this-option-way-too-long
912+ -r, --raspberry-but-making-this-option-way-too-long\u{0020}
913913 raspberry description is also quite long indeed longer
914914 than every other piece of text we might encounter here
915915 and thus will be automatically broken up
@@ -1213,3 +1213,28 @@ fn test_opt_positions() {
12131213 let r_pos = matches. opt_positions ( "r" ) ;
12141214 assert_eq ! ( r_pos, vec![ 2 , 4 , 5 ] ) ;
12151215}
1216+
1217+ #[ test]
1218+ fn test_opt_strs_pos ( ) {
1219+ let mut opts = Options :: new ( ) ;
1220+ opts. optmulti ( "a" , "act" , "Description" , "NUM" ) ;
1221+ opts. optmulti ( "e" , "enact" , "Description" , "NUM" ) ;
1222+ opts. optmulti ( "r" , "react" , "Description" , "NUM" ) ;
1223+
1224+ let args: Vec < String > = [ "-a1" , "-a2" , "-r3" , "-a4" , "-r5" , "-r6" ]
1225+ . iter ( )
1226+ . map ( |x| x. to_string ( ) )
1227+ . collect ( ) ;
1228+
1229+ let matches = & match opts. parse ( & args) {
1230+ Ok ( m) => m,
1231+ Err ( e) => panic ! ( "{}" , e) ,
1232+ } ;
1233+
1234+ let a_pos = matches. opt_strs_pos ( "a" ) ;
1235+ assert_eq ! ( a_pos, vec![ ( 0 , "1" . to_string( ) ) , ( 1 , "2" . to_string( ) ) , ( 3 , "4" . to_string( ) ) ] ) ;
1236+ let e_pos = matches. opt_strs_pos ( "e" ) ;
1237+ assert_eq ! ( e_pos, vec![ ] ) ;
1238+ let r_pos = matches. opt_strs_pos ( "r" ) ;
1239+ assert_eq ! ( r_pos, vec![ ( 2 , "3" . to_string( ) ) , ( 4 , "5" . to_string( ) ) , ( 5 , "6" . to_string( ) ) ] ) ;
1240+ }
0 commit comments