Skip to content

Commit a66f068

Browse files
committed
getopts: add test for strings with spaces.
1 parent 8e9be03 commit a66f068

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/test/stdtest/getopts.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,11 @@ fn test_unrecognized_option_short() {
444444
fn test_combined() {
445445
let args =
446446
["prog", "free1", "-s", "20", "free2", "--flag", "--long=30", "-f",
447-
"-m", "40", "-m", "50"];
447+
"-m", "40", "-m", "50", "-n", "-A B", "-n", "-60 70"];
448448
let opts =
449449
[opt::optopt("s"), opt::optflag("flag"), opt::reqopt("long"),
450-
opt::optflag("f"), opt::optmulti("m"), opt::optopt("notpresent")];
450+
opt::optflag("f"), opt::optmulti("m"), opt::optmulti("n"),
451+
opt::optopt("notpresent")];
451452
let rs = opt::getopts(args, opts);
452453
alt rs {
453454
ok(m) {
@@ -460,6 +461,8 @@ fn test_combined() {
460461
assert (opt::opt_present(m, "f"));
461462
assert (opt::opt_strs(m, "m")[0] == "40");
462463
assert (opt::opt_strs(m, "m")[1] == "50");
464+
assert (opt::opt_strs(m, "n")[0] == "-A B");
465+
assert (opt::opt_strs(m, "n")[1] == "-60 70");
463466
assert (!opt::opt_present(m, "notpresent"));
464467
}
465468
_ { fail; }

0 commit comments

Comments
 (0)