From 43944cadfe7d41df2d68ac44dfd05fc991196b70 Mon Sep 17 00:00:00 2001 From: jpk Date: Thu, 15 Dec 2022 13:33:11 +0100 Subject: [PATCH] Added simple unit test --- src/tohex.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/tohex.rs b/src/tohex.rs index ab4965d..978eee9 100644 --- a/src/tohex.rs +++ b/src/tohex.rs @@ -58,3 +58,23 @@ pub fn hexdump(mut reader: Box, length: usize) { } } } + +#[cfg(test)] +mod tests { + use super::{dump_to_chr, dump_to_hex}; + + #[test] + fn dump_to_chr_test() { + let mut buf = [0; 1]; + assert_eq!("\u{1b}[38;5;8m.\u{1b}[39m", dump_to_chr(&mut buf[0..1])); + } + + #[test] + fn dump_to_hex_test() { + let mut buf = [0; 1]; + assert_eq!( + "\u{1b}[38;5;8m00\u{1b}[39m ", + dump_to_hex(&mut buf[0..1]) + ); + } +}