getopts: add test for strings with spaces.

This commit is contained in:
Erick Tryzelaar 2011-12-13 19:59:12 -08:00
parent 8e9be037d1
commit a66f0688fd

View file

@ -444,10 +444,11 @@ fn test_unrecognized_option_short() {
fn test_combined() {
let args =
["prog", "free1", "-s", "20", "free2", "--flag", "--long=30", "-f",
"-m", "40", "-m", "50"];
"-m", "40", "-m", "50", "-n", "-A B", "-n", "-60 70"];
let opts =
[opt::optopt("s"), opt::optflag("flag"), opt::reqopt("long"),
opt::optflag("f"), opt::optmulti("m"), opt::optopt("notpresent")];
opt::optflag("f"), opt::optmulti("m"), opt::optmulti("n"),
opt::optopt("notpresent")];
let rs = opt::getopts(args, opts);
alt rs {
ok(m) {
@ -460,6 +461,8 @@ fn test_combined() {
assert (opt::opt_present(m, "f"));
assert (opt::opt_strs(m, "m")[0] == "40");
assert (opt::opt_strs(m, "m")[1] == "50");
assert (opt::opt_strs(m, "n")[0] == "-A B");
assert (opt::opt_strs(m, "n")[1] == "-60 70");
assert (!opt::opt_present(m, "notpresent"));
}
_ { fail; }