clap/clap_derive/tests/boxed.rs
2020-02-13 18:21:01 +03:00

32 lines
592 B
Rust

use clap::Clap;
#[test]
fn boxed_flatten_subcommand() {
#[derive(Clap, PartialEq, Debug)]
struct Opt {
#[clap(subcommand)]
sub: Box<Sub>,
}
#[derive(Clap, PartialEq, Debug)]
enum Sub {
Flame {
#[clap(flatten)]
arg: Box<Ext>,
},
}
#[derive(Clap, PartialEq, Debug)]
struct Ext {
arg: u32,
}
assert_eq!(
Opt {
sub: Box::new(Sub::Flame {
arg: Box::new(Ext { arg: 1 })
})
},
Opt::parse_from(&["test", "flame", "1"])
);
}