@@ -176,57 +176,57 @@ mod test {
176
176
177
177
#[test]
178
178
fn test_parse_by_name() {
179
- assert red().eq(&unwrap(parse_color(~" red")));
180
- assert lime().eq(&unwrap(parse_color(~" Lime ")));
181
- assert blue().eq(&unwrap(parse_color(~" BLUE ")));
182
- assert green().eq(&unwrap(parse_color(~" GreEN ")));
183
- assert white().eq(&unwrap(parse_color(~" white")));
184
- assert black().eq(&unwrap(parse_color(~" Black ")));
185
- assert gray().eq(&unwrap(parse_color(~" Gray ")));
186
- assert silver().eq(&unwrap(parse_color(~" SiLvEr ")));
187
- assert maroon().eq(&unwrap(parse_color(~" maroon")));
188
- assert purple().eq(&unwrap(parse_color(~" PURPLE ")));
189
- assert fuchsia().eq(&unwrap(parse_color(~" FUCHSIA ")));
190
- assert olive().eq(&unwrap(parse_color(~" oLiVe")));
191
- assert yellow().eq(&unwrap(parse_color(~" yellow")));
192
- assert navy().eq(&unwrap(parse_color(~" NAVY ")));
193
- assert teal().eq(&unwrap(parse_color(~" Teal ")));
194
- assert aqua().eq(&unwrap(parse_color(~" Aqua ")));
195
- assert None == parse_color(~" foobarbaz");
179
+ fail_unless!( red().eq(&unwrap(parse_color(~" red") )));
180
+ fail_unless!( lime().eq(&unwrap(parse_color(~" Lime ") )));
181
+ fail_unless!( blue().eq(&unwrap(parse_color(~" BLUE ") )));
182
+ fail_unless!( green().eq(&unwrap(parse_color(~" GreEN ") )));
183
+ fail_unless!( white().eq(&unwrap(parse_color(~" white") )));
184
+ fail_unless!( black().eq(&unwrap(parse_color(~" Black ") )));
185
+ fail_unless!( gray().eq(&unwrap(parse_color(~" Gray ") )));
186
+ fail_unless!( silver().eq(&unwrap(parse_color(~" SiLvEr ") )));
187
+ fail_unless!( maroon().eq(&unwrap(parse_color(~" maroon") )));
188
+ fail_unless!( purple().eq(&unwrap(parse_color(~" PURPLE ") )));
189
+ fail_unless!( fuchsia().eq(&unwrap(parse_color(~" FUCHSIA ") )));
190
+ fail_unless!( olive().eq(&unwrap(parse_color(~" oLiVe") )));
191
+ fail_unless!( yellow().eq(&unwrap(parse_color(~" yellow") )));
192
+ fail_unless!( navy().eq(&unwrap(parse_color(~" NAVY ") )));
193
+ fail_unless!( teal().eq(&unwrap(parse_color(~" Teal ") )));
194
+ fail_unless!( aqua().eq(&unwrap(parse_color(~" Aqua ") )));
195
+ fail_unless!( None == parse_color(~" foobarbaz") );
196
196
}
197
197
198
198
#[test]
199
199
fn test_parsing_rgb() {
200
- assert red().eq(&unwrap(parse_color(~" rgb( 255 , 0 , 0 ) ")));
201
- assert red().eq(&unwrap(parse_color(~" rgba( 255 , 0 , 0 , 1.0 ) ")));
202
- assert red().eq(&unwrap(parse_color(~" rgba( 255 , 0 , 0 , 1 ) ")));
203
- assert lime().eq(&unwrap(parse_color(~" rgba( 0 , 255 , 0 , 1.00 ) ")));
204
- assert rgb(1u8,2u8,3u8).eq(&unwrap(parse_color(~" rgb( 1 , 2 , 03 ) ")));
205
- assert rgba(15u8,250u8,3u8,0.5).eq(&unwrap(parse_color(~" rgba( 15 , 250 , 3 , . 5 ) ")));
206
- assert rgba(15u8,250u8,3u8,0.5).eq(&unwrap(parse_color(~" rgba( 15 , 250 , 3 , 0.5 ) ")));
207
- assert None == parse_color(~" rbga( 1 , 2 , 3 ) ");
200
+ fail_unless!( red().eq(&unwrap(parse_color(~" rgb( 255 , 0 , 0 ) ") )));
201
+ fail_unless!( red().eq(&unwrap(parse_color(~" rgba( 255 , 0 , 0 , 1.0 ) ") )));
202
+ fail_unless!( red().eq(&unwrap(parse_color(~" rgba( 255 , 0 , 0 , 1 ) ") )));
203
+ fail_unless!( lime().eq(&unwrap(parse_color(~" rgba( 0 , 255 , 0 , 1.00 ) ") )));
204
+ fail_unless!( rgb(1u8,2u8,3u8).eq(&unwrap(parse_color(~" rgb( 1 , 2 , 03 ) ") )));
205
+ fail_unless!( rgba(15u8,250u8,3u8,0.5).eq(&unwrap(parse_color(~" rgba( 15 , 250 , 3 , . 5 ) ") )));
206
+ fail_unless!( rgba(15u8,250u8,3u8,0.5).eq(&unwrap(parse_color(~" rgba( 15 , 250 , 3 , 0.5 ) ") )));
207
+ fail_unless!( None == parse_color(~" rbga( 1 , 2 , 3 ) ") );
208
208
}
209
209
210
210
#[test]
211
211
fn test_parsing_hsl() {
212
- assert red().eq(&unwrap(parse_color(~" hsl( 0 , 1 , . 5 ) ")));
213
- assert lime().eq(&unwrap(parse_color(~" hsl( 120.0 , 1.0 , . 5 ) ")));
214
- assert blue().eq(&unwrap(parse_color(~" hsl( 240.0 , 1.0 , . 5 ) ")));
215
- assert green().eq(&unwrap(parse_color(~" hsl( 120.0 , 1.0 , . 25 ) ")));
216
- assert white().eq(&unwrap(parse_color(~" hsl( 1.0 , 1. , 1.0 ) ")));
217
- assert white().eq(&unwrap(parse_color(~" hsl( 129.0 , 0.3 , 1.0 ) ")));
218
- assert black().eq(&unwrap(parse_color(~" hsl( 231.2 , 0.75 , 0.0 ) ")));
219
- assert black().eq(&unwrap(parse_color(~" hsl( 11.2 , 0.0 , 0.0 ) ")));
220
- assert gray().eq(&unwrap(parse_color(~" hsl( 0.0 , 0.0 , 0.5 ) ")));
221
- assert maroon().eq(&unwrap(parse_color(~" hsl( 0.0 , 1.0 , 0.25 ) ")));
222
- assert purple().eq(&unwrap(parse_color(~" hsl( 300.0 , 1.0 , 0.25 ) ")));
223
- assert fuchsia().eq(&unwrap(parse_color(~" hsl( 300 , 1.0 , 0.5 ) ")));
224
- assert olive().eq(&unwrap(parse_color(~" hsl( 60. , 1.0 , 0.25 ) ")));
225
- assert yellow().eq(&unwrap(parse_color(~" hsl( 60. , 1.0 , 0.5 ) ")));
226
- assert navy().eq(&unwrap(parse_color(~" hsl( 240.0 , 1.0 , . 25 ) ")));
227
- assert teal().eq(&unwrap(parse_color(~" hsl( 180.0 , 1.0 , . 25 ) ")));
228
- assert aqua().eq(&unwrap(parse_color(~" hsl( 180.0 , 1.0 , . 5 ) ")));
229
- assert None == parse_color(~" hsl( 1 , 2 , 3 , . 4 ) " ) ;
212
+ fail_unless!( red().eq(&unwrap(parse_color(~" hsl( 0 , 1 , . 5 ) ") )));
213
+ fail_unless!( lime().eq(&unwrap(parse_color(~" hsl( 120.0 , 1.0 , . 5 ) ") )));
214
+ fail_unless!( blue().eq(&unwrap(parse_color(~" hsl( 240.0 , 1.0 , . 5 ) ") )));
215
+ fail_unless!( green().eq(&unwrap(parse_color(~" hsl( 120.0 , 1.0 , . 25 ) ") )));
216
+ fail_unless!( white().eq(&unwrap(parse_color(~" hsl( 1.0 , 1. , 1.0 ) ") )));
217
+ fail_unless!( white().eq(&unwrap(parse_color(~" hsl( 129.0 , 0.3 , 1.0 ) ") )));
218
+ fail_unless!( black().eq(&unwrap(parse_color(~" hsl( 231.2 , 0.75 , 0.0 ) ") )));
219
+ fail_unless!( black().eq(&unwrap(parse_color(~" hsl( 11.2 , 0.0 , 0.0 ) ") )));
220
+ fail_unless!( gray().eq(&unwrap(parse_color(~" hsl( 0.0 , 0.0 , 0.5 ) ") )));
221
+ fail_unless!( maroon().eq(&unwrap(parse_color(~" hsl( 0.0 , 1.0 , 0.25 ) ") )));
222
+ fail_unless!( purple().eq(&unwrap(parse_color(~" hsl( 300.0 , 1.0 , 0.25 ) ") )));
223
+ fail_unless!( fuchsia().eq(&unwrap(parse_color(~" hsl( 300 , 1.0 , 0.5 ) ") )));
224
+ fail_unless!( olive().eq(&unwrap(parse_color(~" hsl( 60. , 1.0 , 0.25 ) ") )));
225
+ fail_unless!( yellow().eq(&unwrap(parse_color(~" hsl( 60. , 1.0 , 0.5 ) ") )));
226
+ fail_unless!( navy().eq(&unwrap(parse_color(~" hsl( 240.0 , 1.0 , . 25 ) ") )));
227
+ fail_unless!( teal().eq(&unwrap(parse_color(~" hsl( 180.0 , 1.0 , . 25 ) ") )));
228
+ fail_unless!( aqua().eq(&unwrap(parse_color(~" hsl( 180.0 , 1.0 , . 5 ) ") )));
229
+ fail_unless!( None == parse_color(~" hsl( 1 , 2 , 3 , . 4 ) " ) ) ;
230
230
}
231
231
}
232
232
0 commit comments