Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Commit

Permalink
Update mod test
Browse files Browse the repository at this point in the history
  • Loading branch information
recrack committed Aug 20, 2013
1 parent 9549be4 commit f7825f8
Showing 1 changed file with 0 additions and 64 deletions.
64 changes: 0 additions & 64 deletions color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,69 +227,6 @@ pub fn parse_by_name(name : &str) -> Option<Color> {
}
}
#[cfg(test)]
mod test {
use super::{rgb, rgba};
use super::css_colors::*;
use super::parsing::parse_color;
#[test]
fn test_parse_by_name() {
assert!(red().eq(&parse_color("red").unwrap()));
assert!(lime().eq(&parse_color("Lime").unwrap()));
assert!(blue().eq(&parse_color("BLUE").unwrap()));
assert!(green().eq(&parse_color("GreEN").unwrap()));
assert!(white().eq(&parse_color("white").unwrap()));
assert!(black().eq(&parse_color("Black").unwrap()));
assert!(gray().eq(&parse_color("Gray").unwrap()));
println("silver");
assert!(silver().eq(&parse_color("SiLvEr").unwrap()));
assert!(maroon().eq(&parse_color("maroon").unwrap()));
assert!(purple().eq(&parse_color("PURPLE").unwrap()));
assert!(fuchsia().eq(&parse_color("FUCHSIA").unwrap()));
assert!(olive().eq(&parse_color("oLiVe").unwrap()));
assert!(yellow().eq(&parse_color("yellow").unwrap()));
assert!(navy().eq(&parse_color("NAVY").unwrap()));
assert!(teal().eq(&parse_color("Teal").unwrap()));
assert!(aqua().eq(&parse_color("Aqua").unwrap()));
assert!(None == parse_color("foobarbaz"));
}
#[test]
fn test_parsing_rgb() {
assert!(red().eq(&parse_color("rgb(255,0,0)").unwrap()));
assert!(red().eq(&parse_color("rgba(255,0,0,1.0)").unwrap()));
assert!(red().eq(&parse_color("rgba(255,0,0,1)").unwrap()));
assert!(lime().eq(&parse_color("rgba(0,255,0,1.00)").unwrap()));
assert!(rgb(1u8,2u8,3u8).eq(&parse_color("rgb(1,2,03)").unwrap()));
assert!(rgba(15u8,250u8,3u8,0.5).eq(&parse_color("rgba(15,250,3,.5)").unwrap()));
assert!(rgba(15u8,250u8,3u8,0.5).eq(&parse_color("rgba(15,250,3,0.5)").unwrap()));
assert!(None == parse_color("rbga(1,2,3)"));
}
#[test]
fn test_parsing_hsl() {
assert!(red().eq(&parse_color("hsl(0,1,.5)").unwrap()));
assert!(lime().eq(&parse_color("hsl(120.0,1.0,.5)").unwrap()));
assert!(blue().eq(&parse_color("hsl(240.0,1.0,.5)").unwrap()));
assert!(green().eq(&parse_color("hsl(120.0,1.0,.25)").unwrap()));
assert!(white().eq(&parse_color("hsl(1.0,1.,1.0)").unwrap()));
assert!(white().eq(&parse_color("hsl(129.0,0.3,1.0)").unwrap()));
assert!(black().eq(&parse_color("hsl(231.2,0.75,0.0)").unwrap()));
assert!(black().eq(&parse_color("hsl(11.2,0.0,0.0)").unwrap()));
assert!(gray().eq(&parse_color("hsl(0.0,0.0,0.5)").unwrap()));
assert!(maroon().eq(&parse_color("hsl(0.0,1.0,0.25)").unwrap()));
assert!(purple().eq(&parse_color("hsl(300.0,1.0,0.25)").unwrap()));
assert!(fuchsia().eq(&parse_color("hsl(300,1.0,0.5)").unwrap()));
assert!(olive().eq(&parse_color("hsl(60.,1.0,0.25)").unwrap()));
assert!(yellow().eq(&parse_color("hsl(60.,1.0,0.5)").unwrap()));
assert!(navy().eq(&parse_color("hsl(240.0,1.0,.25)").unwrap()));
assert!(teal().eq(&parse_color("hsl(180.0,1.0,.25)").unwrap()));
assert!(aqua().eq(&parse_color("hsl(180.0,1.0,.5)").unwrap()));
assert!(None == parse_color("hsl(1,2,3,.4)"));
}
}
// Define the colors specified by css
define_color!(ALICEBLUE, 240, 248, 255)
define_color!(ANTIQUEWHITE, 250, 235, 215)
Expand Down Expand Up @@ -478,4 +415,3 @@ mod test {
assert!(None == parse_color("hsl(1,2,3,.4)"));
}
}
>>>>>>> 23872aa... Update

0 comments on commit f7825f8

Please sign in to comment.