Add a basic test

This commit is contained in:
Jake Howard 2017-07-12 14:49:53 +01:00
parent 7013a3e0a0
commit 48cc0f26e3
Signed by: jake
GPG key ID: 57AFB45680EDD477
2 changed files with 11 additions and 2 deletions

View file

@ -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);
}

View file

@ -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());
} }