@@ -55,36 +55,45 @@ fn non_existing_arg() {
55
55
56
56
#[ test]
57
57
fn group_single_value ( ) {
58
- let m = App :: new ( "group" )
58
+ let res = App :: new ( "group" )
59
59
. args_from_usage ( "-f, --flag 'some flag'
60
60
-c, --color [color] 'some option'" )
61
61
. group ( ArgGroup :: with_name ( "grp" )
62
62
. args ( & [ "flag" , "color" ] ) )
63
- . get_matches_from ( vec ! [ "" , "-c" , "blue" ] ) ;
63
+ . get_matches_from_safe ( vec ! [ "" , "-c" , "blue" ] ) ;
64
+ assert ! ( res. is_ok( ) ) ;
65
+
66
+ let m = res. unwrap ( ) ;
64
67
assert ! ( m. is_present( "grp" ) ) ;
65
68
assert_eq ! ( m. value_of( "grp" ) . unwrap( ) , "blue" ) ;
66
69
}
67
70
68
71
#[ test]
69
72
fn group_single_flag ( ) {
70
- let m = App :: new ( "group" )
73
+ let res = App :: new ( "group" )
71
74
. args_from_usage ( "-f, --flag 'some flag'
72
75
-c, --color [color] 'some option'" )
73
76
. group ( ArgGroup :: with_name ( "grp" )
74
77
. args ( & [ "flag" , "color" ] ) )
75
- . get_matches_from ( vec ! [ "" , "-f" ] ) ;
78
+ . get_matches_from_safe ( vec ! [ "" , "-f" ] ) ;
79
+ assert ! ( res. is_ok( ) ) ;
80
+
81
+ let m = res. unwrap ( ) ;
76
82
assert ! ( m. is_present( "grp" ) ) ;
77
83
assert ! ( m. value_of( "grp" ) . is_none( ) ) ;
78
84
}
79
85
80
86
#[ test]
81
87
fn group_empty ( ) {
82
- let m = App :: new ( "group" )
88
+ let res = App :: new ( "group" )
83
89
. args_from_usage ( "-f, --flag 'some flag'
84
90
-c, --color [color] 'some option'" )
85
91
. group ( ArgGroup :: with_name ( "grp" )
86
92
. args ( & [ "flag" , "color" ] ) )
87
- . get_matches_from ( vec ! [ "" ] ) ;
93
+ . get_matches_from_safe ( vec ! [ "" ] ) ;
94
+ assert ! ( res. is_ok( ) ) ;
95
+
96
+ let m = res. unwrap ( ) ;
88
97
assert ! ( !m. is_present( "grp" ) ) ;
89
98
assert ! ( m. value_of( "grp" ) . is_none( ) ) ;
90
99
}
@@ -105,12 +114,15 @@ fn group_reqired_flags_empty() {
105
114
106
115
#[ test]
107
116
fn group_multi_value_single_arg ( ) {
108
- let m = App :: new ( "group" )
117
+ let res = App :: new ( "group" )
109
118
. args_from_usage ( "-f, --flag 'some flag'
110
119
-c, --color [color]... 'some option'" )
111
120
. group ( ArgGroup :: with_name ( "grp" )
112
121
. args ( & [ "flag" , "color" ] ) )
113
- . get_matches_from ( vec ! [ "" , "-c" , "blue" , "red" , "green" ] ) ;
122
+ . get_matches_from_safe ( vec ! [ "" , "-c" , "blue" , "red" , "green" ] ) ;
123
+ assert ! ( res. is_ok( ) , "{:?}" , res. unwrap_err( ) . kind) ;
124
+
125
+ let m = res. unwrap ( ) ;
114
126
assert ! ( m. is_present( "grp" ) ) ;
115
127
assert_eq ! ( & * m. values_of( "grp" ) . unwrap( ) . collect:: <Vec <_>>( ) , & [ "blue" , "red" , "green" ] ) ;
116
128
}
@@ -148,19 +160,7 @@ fn req_group_with_conflict_usage_string() {
148
160
. args ( & [ "base" , "delete" ] )
149
161
. required ( true ) ) ;
150
162
151
- assert ! ( test:: compare_output( app, "clap-test --delete base" , REQ_GROUP_CONFLICT_REV , true ) ) ;
152
- }
153
-
154
- #[ test]
155
- fn req_group_with_conflict_rev_usage_string ( ) {
156
- let app = App :: new ( "req_group" )
157
- . arg ( Arg :: from_usage ( "[base] 'Base commit'" ) . conflicts_with ( "delete" ) )
158
- . arg ( Arg :: from_usage ( "-d, --delete 'Remove the base commit information'" ) )
159
- . group ( ArgGroup :: with_name ( "base_or_delete" )
160
- . args ( & [ "base" , "delete" ] )
161
- . required ( true ) ) ;
162
-
163
- assert ! ( test:: compare_output( app, "clap-test base --delete" , REQ_GROUP_CONFLICT_USAGE , true ) ) ;
163
+ assert ! ( test:: compare_output2( app, "clap-test --delete base" , REQ_GROUP_CONFLICT_REV , REQ_GROUP_CONFLICT_USAGE , true ) ) ;
164
164
}
165
165
166
166
#[ test]
0 commit comments