Add a basic test
This commit is contained in:
parent
7013a3e0a0
commit
48cc0f26e3
2 changed files with 11 additions and 2 deletions
|
@ -1,5 +1,8 @@
|
||||||
use clap::{App, AppSettings, ArgMatches};
|
use clap::{App, AppSettings, ArgMatches};
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
use clap::Result;
|
||||||
|
|
||||||
|
|
||||||
fn build() -> App<'static, 'static> {
|
fn build() -> App<'static, 'static> {
|
||||||
return App::new(crate_name!())
|
return App::new(crate_name!())
|
||||||
|
@ -17,3 +20,8 @@ fn build() -> App<'static, 'static> {
|
||||||
pub fn get_matches() -> ArgMatches<'static> {
|
pub fn get_matches() -> ArgMatches<'static> {
|
||||||
return build().get_matches();
|
return build().get_matches();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub fn get_matches_for(args : Vec<String>) -> Result<ArgMatches<'static>> {
|
||||||
|
return build().get_matches_from_safe(args);
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use args;
|
use args;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works() {
|
fn error_if_no_subcommand() {
|
||||||
assert_eq!(4, 4);
|
let out = args::get_matches_for(vec!("mdp".into()));
|
||||||
|
assert!(out.is_err());
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue