From 30dd75658879e52940191d6733113d2b4a69fa46 Mon Sep 17 00:00:00 2001 From: Frederik B Date: Sun, 15 Apr 2018 22:29:48 +0200 Subject: [PATCH] add tests for formatted strings (#130) --- src/proto/colors.rs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/proto/colors.rs b/src/proto/colors.rs index 7da5e61..e448e46 100644 --- a/src/proto/colors.rs +++ b/src/proto/colors.rs @@ -92,3 +92,40 @@ impl FormattedStringExt for String { (&self[..]).strip_formatting() } } + +#[cfg(test)] +mod test { + use proto::colors::FormattedStringExt; + + #[test] + fn test_strip_bold() { + assert_eq!("l\x02ol".strip_formatting(), "lol"); + } + + #[test] + fn test_strip_fg_color() { + assert_eq!("l\x033ol".strip_formatting(), "lol"); + } + + #[test] + fn test_strip_fg_color2() { + assert_eq!("l\x0312ol".strip_formatting(), "lol"); + } + + #[test] + fn test_strip_fg_bg_11() { + assert_eq!("l\x031,2ol".strip_formatting(), "lol"); + } + #[test] + fn test_strip_fg_bg_21() { + assert_eq!("l\x0312,3ol".strip_formatting(), "lol"); + } + #[test] + fn test_strip_fg_bg_12() { + assert_eq!("l\x031,12ol".strip_formatting(), "lol"); + } + #[test] + fn test_strip_fg_bg_22() { + assert_eq!("l\x0312,13ol".strip_formatting(), "lol"); + } +} \ No newline at end of file