Skip to content

Commit

Permalink
test: Add tests for 12-bit color
Browse files Browse the repository at this point in the history
  • Loading branch information
joshtriplett committed Jul 13, 2024
1 parent 4fa09f7 commit 1ec0b40
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions crates/anstyle-git/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,14 @@ mod tests {
test!("255 -1" => Ansi256Color(255).on_default());
test!("#000000" => RgbColor(0,0,0).on_default());
test!("#204060" => RgbColor(0x20,0x40,0x60).on_default());
test!("#1a2b3c" => RgbColor(0x1a,0x2b,0x3c).on_default());
test!("#000" => RgbColor(0,0,0).on_default());
test!("#cba" => RgbColor(0xc,0xb,0xa).on_default());
test!("#cba " => RgbColor(0xc,0xb,0xa).on_default());
test!("#987 #135" => RgbColor(9,8,7).on(RgbColor(1, 3, 5)));
test!("#987 #135 " => RgbColor(9,8,7).on(RgbColor(1, 3, 5)));
test!("#123 #abcdef" => RgbColor(1,2,3).on(RgbColor(0xab, 0xcd, 0xef)));
test!("#654321 #a9b" => RgbColor(0x65,0x43,0x21).on(RgbColor(0xa, 0x9, 0xb)));

test!("bold cyan white" => Cyan.on(White).bold());
test!("bold cyan nobold white" => Cyan.on(White));
Expand All @@ -226,6 +234,8 @@ mod tests {
test!("italic cyan white" => Cyan.on(White).italic());
test!("strike cyan white" => Cyan.on(White).strikethrough());
test!("blink #050505 white" => RgbColor(5,5,5).on(White).blink());
test!("bold #987 green" => RgbColor(9,8,7).on(Green).bold());
test!("strike #147 #cba" => RgbColor(1,4,7).on(RgbColor(0xc, 0xb, 0xa)).strikethrough());
}

#[test]
Expand All @@ -249,6 +259,9 @@ mod tests {
test!("red blue -1" => ExtraColor "-1");
test!("yellow green #abcdef" => ExtraColor "#abcdef");
test!("#123456 #654321 #abcdef" => ExtraColor "#abcdef");
test!("#123 #654 #abc" => ExtraColor "#abc");
test!("#123 #654 #abcdef" => ExtraColor "#abcdef");
test!("#123456 #654321 #abc" => ExtraColor "#abc");
test!("bold red blue green" => ExtraColor "green");
test!("red bold blue green" => ExtraColor "green");
test!("red blue bold green" => ExtraColor "green");
Expand All @@ -270,8 +283,14 @@ mod tests {
test!("no-green" => UnknownWord "no-green");
test!("no-#123456" => UnknownWord "no-#123456");
test!("#" => UnknownWord "#");
test!("#1" => UnknownWord "#1");
test!("#12" => UnknownWord "#12");
test!("#1234" => UnknownWord "#1234");
test!("#12345" => UnknownWord "#12345");
test!("#1234567" => UnknownWord "#1234567");
test!("#12345678" => UnknownWord "#12345678");
test!("#123456789" => UnknownWord "#123456789");
test!("#123456789abc" => UnknownWord "#123456789abc");
test!("#bcdefg" => UnknownWord "#bcdefg");
test!("#blue" => UnknownWord "#blue");
test!("blue#123456" => UnknownWord "blue#123456");
Expand Down

0 comments on commit 1ec0b40

Please sign in to comment.