tests(arg_enum): adds tests

This commit is contained in:
Kevin K 2015-05-05 18:28:16 -04:00
parent 73d5a974eb
commit a3e0671336

View file

@ -367,6 +367,80 @@ mod tests {
use super::{App, Arg, SubCommand};
use std::collections::HashSet;
arg_enum!{
#[derive(Debug)]
enum Val1 {
ValOne,
ValTwo
}
}
arg_enum!{
#[derive(Debug)]
pub enum Val2 {
ValOne,
ValTwo
}
}
arg_enum!{
enum Val3 {
ValOne,
ValTwo
}
}
arg_enum!{
pub enum Val4 {
ValOne,
ValTwo
}
}
#[test]
fn test_enums() {
let v1_lower = "valone";
let v1_camel = "ValOne";
let v1_lp = v1_lower.parse::<Val1>().unwrap();
let v1_cp = v1_camel.parse::<Val1>().unwrap();
match v1_lp {
Val1::ValOne => (),
_ => panic!("Val1 didn't parse correctly"),
}
match v1_cp {
Val1::ValOne => (),
_ => panic!("Val1 didn't parse correctly"),
}
let v1_lp = v1_lower.parse::<Val2>().unwrap();
let v1_cp = v1_camel.parse::<Val2>().unwrap();
match v1_lp {
Val2::ValOne => (),
_ => panic!("Val1 didn't parse correctly"),
}
match v1_cp {
Val2::ValOne => (),
_ => panic!("Val1 didn't parse correctly"),
}
let v1_lp = v1_lower.parse::<Val3>().unwrap();
let v1_cp = v1_camel.parse::<Val3>().unwrap();
match v1_lp {
Val3::ValOne => (),
_ => panic!("Val1 didn't parse correctly"),
}
match v1_cp {
Val3::ValOne => (),
_ => panic!("Val1 didn't parse correctly"),
}
let v1_lp = v1_lower.parse::<Val4>().unwrap();
let v1_cp = v1_camel.parse::<Val4>().unwrap();
match v1_lp {
Val4::ValOne => (),
_ => panic!("Val1 didn't parse correctly"),
}
match v1_cp {
Val4::ValOne => (),
_ => panic!("Val1 didn't parse correctly"),
}
}
#[test]
fn create_app() {
let _ = App::new("test").version("1.0").author("kevin").about("does awesome things").get_matches();