File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,9 @@ impl Badge {
53
53
} ;
54
54
let v_metrics = font. v_metrics ( scale) ;
55
55
let offset = point ( 0.0 , v_metrics. ascent ) ;
56
+ if options. status . is_empty ( ) || options. subject . is_empty ( ) {
57
+ return Err ( String :: from ( "status and subject must not be empty" ) ) ;
58
+ }
56
59
Ok ( Badge {
57
60
options : options,
58
61
font : font,
@@ -145,6 +148,14 @@ mod tests {
145
148
#[ test]
146
149
fn test_new ( ) {
147
150
assert ! ( Badge :: new( options( ) ) . is_ok( ) ) ;
151
+
152
+ let mut bad_options_status = options ( ) ;
153
+ bad_options_status. status = "" . to_owned ( ) ;
154
+ assert ! ( Badge :: new( bad_options_status) . is_err( ) ) ;
155
+
156
+ let mut bad_options_subject = options ( ) ;
157
+ bad_options_subject. subject = "" . to_owned ( ) ;
158
+ assert ! ( Badge :: new( bad_options_subject) . is_err( ) ) ;
148
159
}
149
160
150
161
#[ test]
You can’t perform that action at this time.
0 commit comments