From 63dbc5569f1c65df6059d488e2a28e77502cab51 Mon Sep 17 00:00:00 2001 From: Kevin K Date: Fri, 4 Sep 2015 11:38:48 -0400 Subject: [PATCH] tests: adds tests for colored output --- src/fmt.rs | 16 ++++++++++++++++ src/tests.rs | 7 +++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/fmt.rs b/src/fmt.rs index 14b45c0b..d2b361fd 100644 --- a/src/fmt.rs +++ b/src/fmt.rs @@ -48,3 +48,19 @@ impl fmt::Display for Format { write!(f, "{}", &self.format()) } } + +#[cfg(test)] +mod test { + use super::Format; + use ansi_term::Colour::{Red, Green, Yellow}; + + #[test] + fn colored_output() { + let err = Format::Error("error"); + assert_eq!(&*format!("{}", err), &*format!("{}", Red.bold().paint("error"))); + let good = Format::Good("good"); + assert_eq!(&*format!("{}", good), &*format!("{}", Green.paint("good"))); + let warn = Format::Warning("warn"); + assert_eq!(&*format!("{}", warn), &*format!("{}", Yellow.paint("warn"))); + } +} \ No newline at end of file diff --git a/src/tests.rs b/src/tests.rs index 0e16d0cf..8dee6051 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -1,5 +1,6 @@ -use super::{App, Arg, SubCommand}; use std::collections::HashSet; + +use super::{App, Arg, SubCommand}; use std::vec::Vec; arg_enum!{ @@ -906,4 +907,6 @@ fn create_multiple_subcommands() { .arg(Arg::with_name("roster").short("r"))]) .arg(Arg::with_name("other").long("other")) .get_matches(); -} \ No newline at end of file +} + +