Skip to content

Commit 1ec0b40

Browse files
committed
test: Add tests for 12-bit color
1 parent 4fa09f7 commit 1ec0b40

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

crates/anstyle-git/src/lib.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,14 @@ mod tests {
217217
test!("255 -1" => Ansi256Color(255).on_default());
218218
test!("#000000" => RgbColor(0,0,0).on_default());
219219
test!("#204060" => RgbColor(0x20,0x40,0x60).on_default());
220+
test!("#1a2b3c" => RgbColor(0x1a,0x2b,0x3c).on_default());
221+
test!("#000" => RgbColor(0,0,0).on_default());
222+
test!("#cba" => RgbColor(0xc,0xb,0xa).on_default());
223+
test!("#cba " => RgbColor(0xc,0xb,0xa).on_default());
224+
test!("#987 #135" => RgbColor(9,8,7).on(RgbColor(1, 3, 5)));
225+
test!("#987 #135 " => RgbColor(9,8,7).on(RgbColor(1, 3, 5)));
226+
test!("#123 #abcdef" => RgbColor(1,2,3).on(RgbColor(0xab, 0xcd, 0xef)));
227+
test!("#654321 #a9b" => RgbColor(0x65,0x43,0x21).on(RgbColor(0xa, 0x9, 0xb)));
220228

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

231241
#[test]
@@ -249,6 +259,9 @@ mod tests {
249259
test!("red blue -1" => ExtraColor "-1");
250260
test!("yellow green #abcdef" => ExtraColor "#abcdef");
251261
test!("#123456 #654321 #abcdef" => ExtraColor "#abcdef");
262+
test!("#123 #654 #abc" => ExtraColor "#abc");
263+
test!("#123 #654 #abcdef" => ExtraColor "#abcdef");
264+
test!("#123456 #654321 #abc" => ExtraColor "#abc");
252265
test!("bold red blue green" => ExtraColor "green");
253266
test!("red bold blue green" => ExtraColor "green");
254267
test!("red blue bold green" => ExtraColor "green");
@@ -270,8 +283,14 @@ mod tests {
270283
test!("no-green" => UnknownWord "no-green");
271284
test!("no-#123456" => UnknownWord "no-#123456");
272285
test!("#" => UnknownWord "#");
286+
test!("#1" => UnknownWord "#1");
287+
test!("#12" => UnknownWord "#12");
288+
test!("#1234" => UnknownWord "#1234");
273289
test!("#12345" => UnknownWord "#12345");
274290
test!("#1234567" => UnknownWord "#1234567");
291+
test!("#12345678" => UnknownWord "#12345678");
292+
test!("#123456789" => UnknownWord "#123456789");
293+
test!("#123456789abc" => UnknownWord "#123456789abc");
275294
test!("#bcdefg" => UnknownWord "#bcdefg");
276295
test!("#blue" => UnknownWord "#blue");
277296
test!("blue#123456" => UnknownWord "blue#123456");

0 commit comments

Comments
 (0)