mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 06:42:33 +00:00
tests: adds tests for colored output
This commit is contained in:
parent
9b6e3c0a5f
commit
63dbc5569f
2 changed files with 21 additions and 2 deletions
16
src/fmt.rs
16
src/fmt.rs
|
@ -48,3 +48,19 @@ impl<T: fmt::Display> fmt::Display for Format<T> {
|
||||||
write!(f, "{}", &self.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")));
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
use super::{App, Arg, SubCommand};
|
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
|
use super::{App, Arg, SubCommand};
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
|
|
||||||
arg_enum!{
|
arg_enum!{
|
||||||
|
@ -906,4 +907,6 @@ fn create_multiple_subcommands() {
|
||||||
.arg(Arg::with_name("roster").short("r"))])
|
.arg(Arg::with_name("roster").short("r"))])
|
||||||
.arg(Arg::with_name("other").long("other"))
|
.arg(Arg::with_name("other").long("other"))
|
||||||
.get_matches();
|
.get_matches();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue