tests: adds tests for colored output

This commit is contained in:
Kevin K 2015-09-04 11:38:48 -04:00
parent 9b6e3c0a5f
commit 63dbc5569f
2 changed files with 21 additions and 2 deletions

View file

@ -48,3 +48,19 @@ impl<T: fmt::Display> fmt::Display for Format<T> {
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")));
}
}

View file

@ -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();
}
}