#[macro_use]
extern crate clapme;
use clapme::ClapMe;
#[derive(ClapMe, PartialEq, Debug)]
struct Unit;
#[test]
fn unit_struct() {
println!("help: {}", Unit::help_message("foo"));
assert!(!Unit::help_message("foo").contains("--first"));
assert_eq!(Unit,
Unit::from_iter(&[""]).unwrap());
}
#[test]
fn struct_with_unit() {
#[derive(ClapMe, PartialEq, Debug)]
struct Opt {
first: i32,
second: Unit,
};
println!("help: {}", Opt::help_message("foo"));
assert!(Opt::help_message("foo").contains("--first"));
assert!(!Opt::help_message("foo").contains("--second"));
assert_eq!(Opt{ first: 7, second: Unit },
Opt::from_iter(&["","--first=7"]).unwrap());
assert_eq!(None,
Opt::from_iter(&["","--first=7", "--second"]).ok());
assert!(Opt::from_iter(&[""]).is_err());
assert!(Opt::from_iter(&["hello"]).is_err());
assert!(Opt::from_iter(&["--first"]).is_err());
}