Skip to content

Commit

Permalink
Auto merge of #479 - kbknapp:issue-476, r=kbknapp
Browse files Browse the repository at this point in the history
Issue 476

From #477

Relates to #476
  • Loading branch information
homu committed Apr 10, 2016
2 parents 1dd7e56 + c3795ad commit be670e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/app/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b {
for g in grps.into_iter() {
let g_string = self.args_in_group(g)
.join("|");
ret_val.push_back(format!("[{}]", &g_string[..g_string.len() - 1]));
ret_val.push_back(format!("[{}]", &g_string[..g_string.len()]));
}

ret_val
Expand Down
30 changes: 5 additions & 25 deletions tests/groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,33 +79,13 @@ fn group_multi_value_single_arg() {
}

#[test]
#[should_panic]
fn empty_group() {
let _ = App::new("empty_group")
let r = App::new("empty_group")
.arg(Arg::from_usage("-f, --flag 'some flag'"))
.group(ArgGroup::with_name("vers")
.required(true))
.get_matches();
}

#[test]
#[should_panic]
fn empty_group_2() {
let _ = App::new("empty_group")
.arg(Arg::from_usage("-f, --flag 'some flag'"))
.group(ArgGroup::with_name("vers")
.required(true)
.args(&["ver", "major"]))
.get_matches();
}

#[test]
#[should_panic]
fn errous_group() {
let _ = App::new("errous_group")
.arg(Arg::from_usage("-f, --flag 'some flag'"))
.group(ArgGroup::with_name("vers")
.arg("vers")
.required(true))
.get_matches();
.get_matches_from_safe(vec!["empty_prog"]);
assert!(r.is_err());
let err = r.err().unwrap();
assert_eq!(err.kind, ErrorKind::MissingRequiredArgument);
}

0 comments on commit be670e6

Please sign in to comment.