Fixed broken tests
This commit is contained in:
parent
cc6f53979a
commit
e3d1176fa6
2 changed files with 7 additions and 9 deletions
|
@ -77,7 +77,7 @@ pub fn matches(vars: &mut Vars, env_args: &[String]) -> Result<Matches, Error> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Match {
|
pub trait Match {
|
||||||
fn get(&self, arg: &str) -> Option<String>;
|
fn get(&self, arg: &str) -> Option<&String>;
|
||||||
|
|
||||||
fn has_match(&self, arg: &str) -> bool;
|
fn has_match(&self, arg: &str) -> bool;
|
||||||
|
|
||||||
|
@ -85,11 +85,8 @@ pub trait Match {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Match for Matches {
|
impl Match for Matches {
|
||||||
fn get(&self, arg: &str) -> Option<String> {
|
fn get(&self, arg: &str) -> Option<&String> {
|
||||||
match self.get(arg) {
|
self.get(arg)
|
||||||
Some(s) => Some(s.clone()),
|
|
||||||
None => None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn has_match(&self, arg: &str) -> bool {
|
fn has_match(&self, arg: &str) -> bool {
|
||||||
|
@ -118,6 +115,6 @@ mod tests {
|
||||||
};
|
};
|
||||||
|
|
||||||
let argument = matches.get("a").unwrap();
|
let argument = matches.get("a").unwrap();
|
||||||
assert_eq!(argument, String::from("Test"));
|
assert_eq!(*argument, String::from("Test"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,10 @@ use pirate::{Matches, Match, matches, usage, vars};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn main() {
|
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)",
|
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 mut vars = vars("test", &opts).unwrap();
|
||||||
|
|
||||||
let matches: Matches = match matches(&mut vars, &env_args) {
|
let matches: Matches = match matches(&mut vars, &env_args) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue