Added tests to colormap
continuous-integration/drone/push Build is failing Details

This commit is contained in:
jpk 2022-12-16 14:03:57 +01:00
parent b23f7a4de5
commit 9214f188bf
1 changed files with 17 additions and 0 deletions

View File

@ -86,3 +86,20 @@ pub fn map_char_to_color(data: u8) -> String {
}
}
}
#[cfg(test)]
mod tests {
use super::{map_u8_to_color, map_char_to_color};
#[test]
fn map_u8_to_color_test() {
assert_eq!("\u{1b}[38;5;12m32\u{1b}[39m", map_u8_to_color(0x32));
assert_eq!("\u{1b}[38;5;6m64\u{1b}[39m", map_u8_to_color(0x64));
}
#[test]
fn map_char8_to_color_test() {
assert_eq!("\u{1b}[38;5;12m2\u{1b}[39m", map_char_to_color(0x32));
assert_eq!("\u{1b}[38;5;6md\u{1b}[39m", map_char_to_color(0x64));
}
}