blob: 868ae8cc3e745c91c869e98bbfa39b47cad9c89e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
use std::path::PathBuf;
use parser::ArgumentParser;
use super::Parse;
use test_parser::{check_ok};
fn parse_str(args: &[&str]) -> PathBuf {
let mut val: PathBuf = From::from("");
{
let mut ap = ArgumentParser::new();
ap.refer(&mut val)
.add_option(&["-s", "--set"], Parse,
"Set path value");
check_ok(&ap, args);
}
return val;
}
#[test]
fn test_path() {
assert_eq!(parse_str(&["./argparse_test", "-s", "/hello"]),
PathBuf::from("/hello"));
assert_eq!(parse_str(&["./argparse_test", "--set", "a///b/../c"]),
PathBuf::from("a/b/../c"));
}
#[test]
#[should_panic]
fn test_err() {
parse_str(&["./argparse_test", "--set"]);
}
|