@@ -909,7 +909,7 @@ Options:
909
909
-c, --brûlée brûlée quite long description
910
910
-k, --kiwi€ kiwi description
911
911
-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}
913
913
raspberry description is also quite long indeed longer
914
914
than every other piece of text we might encounter here
915
915
and thus will be automatically broken up
@@ -1213,3 +1213,28 @@ fn test_opt_positions() {
1213
1213
let r_pos = matches. opt_positions ( "r" ) ;
1214
1214
assert_eq ! ( r_pos, vec![ 2 , 4 , 5 ] ) ;
1215
1215
}
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