mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Add ansi.c3 for AnsiColor support (#2261)
* Add ansi.c3 for AnsiColor support * Added tests updated functions to macros added formatting codes * Fixed indentation * Update names. Add plain rgb version. Add runtime colors. * Update indentation, add 21-29 --------- Co-authored-by: Christoffer Lerno <christoffer@aegik.com>
This commit is contained in:
25
test/unit/stdlib/core/ansi.c3
Normal file
25
test/unit/stdlib/core/ansi.c3
Normal file
@@ -0,0 +1,25 @@
|
||||
module std::core::string::ansi @test;
|
||||
|
||||
fn void test_color_8bit()
|
||||
{
|
||||
test::eq("\u001B[38;5;255m", ansi::color_8bit(255));
|
||||
test::eq("\u001B[48;5;255m", ansi::color_8bit(255, true));
|
||||
}
|
||||
|
||||
fn void test_color_rgb()
|
||||
{
|
||||
test::eq("\u001B[38;2;255;204;255m", ansi::color_rgb(255, 204, 255));
|
||||
test::eq("\u001B[48;2;255;204;255m", ansi::color_rgb(255, 204, 255, true));
|
||||
}
|
||||
|
||||
fn void test_color()
|
||||
{
|
||||
test::eq("\u001B[38;2;255;204;255m", ansi::color(0xFFCCFF));
|
||||
test::eq("\u001B[48;2;255;204;255m", ansi::color(0xFFCCFF, true));
|
||||
}
|
||||
|
||||
fn void test_make_color()
|
||||
{
|
||||
test::eq("\u001B[38;2;255;204;255m", ansi::make_color(tmem, 0xFFCCFF));
|
||||
test::eq("\u001B[48;2;255;204;255m", ansi::make_color(tmem, 0xFFCCFF, true));
|
||||
}
|
||||
Reference in New Issue
Block a user