Fixed broken tests

This commit is contained in:
Zach Dziura 2015-06-24 17:02:16 -04:00
parent cc6f53979a
commit e3d1176fa6
2 changed files with 7 additions and 9 deletions

View file

@ -77,7 +77,7 @@ pub fn matches(vars: &mut Vars, env_args: &[String]) -> Result<Matches, Error> {
}
pub trait Match {
fn get(&self, arg: &str) -> Option<String>;
fn get(&self, arg: &str) -> Option<&String>;
fn has_match(&self, arg: &str) -> bool;
@ -85,11 +85,8 @@ pub trait Match {
}
impl Match for Matches {
fn get(&self, arg: &str) -> Option<String> {
match self.get(arg) {
Some(s) => Some(s.clone()),
None => None
}
fn get(&self, arg: &str) -> Option<&String> {
self.get(arg)
}
fn has_match(&self, arg: &str) -> bool {
@ -118,6 +115,6 @@ mod tests {
};
let argument = matches.get("a").unwrap();
assert_eq!(argument, String::from("Test"));
assert_eq!(*argument, String::from("Test"));
}
}

View file

@ -4,9 +4,10 @@ use pirate::{Matches, Match, matches, usage, vars};
#[test]
fn main() {
let env_args: Vec<String> = vec![String::from("test"), String::from("-a"), String::from("2"), String::from("3")];
let env_args: Vec<String> = vec![String::from("test"), String::from("-a"), String::from("2"),
String::from("3")];
let opts = vec!["a/addend(The right side of the addition equation; default=1):", "(Required Arguments)",
":augend(The left side of an addition equation)"];
":augend(The left side of an addition equation)"];
let mut vars = vars("test", &opts).unwrap();
let matches: Matches = match matches(&mut vars, &env_args) {