pub mod color;
pub mod printer;
pub mod style;
#[cfg(test)]
mod tests {
use crate::color::*;
use printer::*;
use super::*;
#[test]
fn test_color16_printer() {
let red_fg_text = "this is a red foreground color text".print_c16(FG_RED, BG_BLACK);
assert_eq!(
"\u{001b}[31;40mthis is a red foreground color text\u{001b}[0m",
red_fg_text
);
}
#[test]
fn test_color256_printer() {
let red_fg_text = "this is a red foreground color text".print_c256(1, 0);
let expected = "\u{001b}[38;5;1;48;5;0mthis is a red foreground color text\u{001b}[0m";
assert_eq!(expected, red_fg_text);
}
#[test]
fn test_default_3bit_color() {
let error_text = "white text with red bg".error();
let mut expected = "\u{001b}[37;41mwhite text with red bg\u{001b}[0m";
assert_eq!(expected, error_text);
let primary_text = "blue text with primary style".primary();
expected = "\u{001b}[34;49mblue text with primary style\u{001b}[0m";
assert_eq!(expected, primary_text);
let danger = "red text with danger style".danger();
expected = "\u{001b}[31;49mred text with danger style\u{001b}[0m";
assert_eq!(expected, danger);
let info_text = "green text with info style".info();
expected = "\u{001b}[32;49mgreen text with info style\u{001b}[0m";
assert_eq!(expected, info_text);
let warn_text = "yellow text with warn style".warn();
expected = "\u{001b}[33;49myellow text with warn style\u{001b}[0m";
assert_eq!(expected, warn_text);
let blink_text = "this is a text with blink style".blink();
expected = "\u{001b}[31;5mthis is a text with blink style\u{001b}[0m";
assert_eq!(expected, blink_text);
let underlined_text = "this is a text with underlined style".underline();
expected = "\u{001b}[33;4mthis is a text with underlined style\u{001b}[0m";
assert_eq!(expected, underlined_text);
}
#[test]
fn test_darken() {
let result = darken(FG_LIGHT_RED);
assert_eq!(FG_RED, result);
}
#[test]
fn test_lighten() {
let result = lighten(FG_RED);
assert_eq!(FG_LIGHT_RED, result);
}
}