|
|
@@ -29,6 +29,7 @@ fn check_fail_type(opt::fail_ f, fail_type ft) { |
|
|
|
|
|
|
|
|
// Tests for reqopt |
|
|
#[test] |
|
|
fn test_reqopt_long() { |
|
|
auto args = ["--test=20"]; |
|
|
auto opts = [opt::reqopt("test")]; |
|
|
@@ -42,6 +43,7 @@ fn test_reqopt_long() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_reqopt_long_missing() { |
|
|
auto args = ["blah"]; |
|
|
auto opts = [opt::reqopt("test")]; |
|
|
@@ -52,6 +54,7 @@ fn test_reqopt_long_missing() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_reqopt_long_no_arg() { |
|
|
auto args = ["--test"]; |
|
|
auto opts = [opt::reqopt("test")]; |
|
|
@@ -62,6 +65,7 @@ fn test_reqopt_long_no_arg() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_reqopt_long_multi() { |
|
|
auto args = ["--test=20", "--test=30"]; |
|
|
auto opts = [opt::reqopt("test")]; |
|
|
@@ -72,6 +76,7 @@ fn test_reqopt_long_multi() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_reqopt_short() { |
|
|
auto args = ["-t", "20"]; |
|
|
auto opts = [opt::reqopt("t")]; |
|
|
@@ -85,6 +90,7 @@ fn test_reqopt_short() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_reqopt_short_missing() { |
|
|
auto args = ["blah"]; |
|
|
auto opts = [opt::reqopt("t")]; |
|
|
@@ -95,6 +101,7 @@ fn test_reqopt_short_missing() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_reqopt_short_no_arg() { |
|
|
auto args = ["-t"]; |
|
|
auto opts = [opt::reqopt("t")]; |
|
|
@@ -105,6 +112,7 @@ fn test_reqopt_short_no_arg() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_reqopt_short_multi() { |
|
|
auto args = ["-t", "20", "-t", "30"]; |
|
|
auto opts = [opt::reqopt("t")]; |
|
|
@@ -117,6 +125,7 @@ fn test_reqopt_short_multi() { |
|
|
|
|
|
|
|
|
// Tests for optopt |
|
|
#[test] |
|
|
fn test_optopt_long() { |
|
|
auto args = ["--test=20"]; |
|
|
auto opts = [opt::optopt("test")]; |
|
|
@@ -130,6 +139,7 @@ fn test_optopt_long() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_optopt_long_missing() { |
|
|
auto args = ["blah"]; |
|
|
auto opts = [opt::optopt("test")]; |
|
|
@@ -140,6 +150,7 @@ fn test_optopt_long_missing() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_optopt_long_no_arg() { |
|
|
auto args = ["--test"]; |
|
|
auto opts = [opt::optopt("test")]; |
|
|
@@ -150,6 +161,7 @@ fn test_optopt_long_no_arg() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_optopt_long_multi() { |
|
|
auto args = ["--test=20", "--test=30"]; |
|
|
auto opts = [opt::optopt("test")]; |
|
|
@@ -160,6 +172,7 @@ fn test_optopt_long_multi() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_optopt_short() { |
|
|
auto args = ["-t", "20"]; |
|
|
auto opts = [opt::optopt("t")]; |
|
|
@@ -173,6 +186,7 @@ fn test_optopt_short() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_optopt_short_missing() { |
|
|
auto args = ["blah"]; |
|
|
auto opts = [opt::optopt("t")]; |
|
|
@@ -183,6 +197,7 @@ fn test_optopt_short_missing() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_optopt_short_no_arg() { |
|
|
auto args = ["-t"]; |
|
|
auto opts = [opt::optopt("t")]; |
|
|
@@ -193,6 +208,7 @@ fn test_optopt_short_no_arg() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_optopt_short_multi() { |
|
|
auto args = ["-t", "20", "-t", "30"]; |
|
|
auto opts = [opt::optopt("t")]; |
|
|
@@ -205,6 +221,7 @@ fn test_optopt_short_multi() { |
|
|
|
|
|
|
|
|
// Tests for optflag |
|
|
#[test] |
|
|
fn test_optflag_long() { |
|
|
auto args = ["--test"]; |
|
|
auto opts = [opt::optflag("test")]; |
|
|
@@ -215,6 +232,7 @@ fn test_optflag_long() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_optflag_long_missing() { |
|
|
auto args = ["blah"]; |
|
|
auto opts = [opt::optflag("test")]; |
|
|
@@ -225,6 +243,7 @@ fn test_optflag_long_missing() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_optflag_long_arg() { |
|
|
auto args = ["--test=20"]; |
|
|
auto opts = [opt::optflag("test")]; |
|
|
@@ -238,6 +257,7 @@ fn test_optflag_long_arg() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_optflag_long_multi() { |
|
|
auto args = ["--test", "--test"]; |
|
|
auto opts = [opt::optflag("test")]; |
|
|
@@ -248,6 +268,7 @@ fn test_optflag_long_multi() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_optflag_short() { |
|
|
auto args = ["-t"]; |
|
|
auto opts = [opt::optflag("t")]; |
|
|
@@ -258,6 +279,7 @@ fn test_optflag_short() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_optflag_short_missing() { |
|
|
auto args = ["blah"]; |
|
|
auto opts = [opt::optflag("t")]; |
|
|
@@ -268,6 +290,7 @@ fn test_optflag_short_missing() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_optflag_short_arg() { |
|
|
auto args = ["-t", "20"]; |
|
|
auto opts = [opt::optflag("t")]; |
|
|
@@ -282,6 +305,7 @@ fn test_optflag_short_arg() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_optflag_short_multi() { |
|
|
auto args = ["-t", "-t"]; |
|
|
auto opts = [opt::optflag("t")]; |
|
|
@@ -294,6 +318,7 @@ fn test_optflag_short_multi() { |
|
|
|
|
|
|
|
|
// Tests for optmulti |
|
|
#[test] |
|
|
fn test_optmulti_long() { |
|
|
auto args = ["--test=20"]; |
|
|
auto opts = [opt::optmulti("test")]; |
|
|
@@ -307,6 +332,7 @@ fn test_optmulti_long() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_optmulti_long_missing() { |
|
|
auto args = ["blah"]; |
|
|
auto opts = [opt::optmulti("test")]; |
|
|
@@ -317,6 +343,7 @@ fn test_optmulti_long_missing() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_optmulti_long_no_arg() { |
|
|
auto args = ["--test"]; |
|
|
auto opts = [opt::optmulti("test")]; |
|
|
@@ -327,6 +354,7 @@ fn test_optmulti_long_no_arg() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_optmulti_long_multi() { |
|
|
auto args = ["--test=20", "--test=30"]; |
|
|
auto opts = [opt::optmulti("test")]; |
|
|
@@ -342,6 +370,7 @@ fn test_optmulti_long_multi() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_optmulti_short() { |
|
|
auto args = ["-t", "20"]; |
|
|
auto opts = [opt::optmulti("t")]; |
|
|
@@ -355,6 +384,7 @@ fn test_optmulti_short() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_optmulti_short_missing() { |
|
|
auto args = ["blah"]; |
|
|
auto opts = [opt::optmulti("t")]; |
|
|
@@ -365,6 +395,7 @@ fn test_optmulti_short_missing() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_optmulti_short_no_arg() { |
|
|
auto args = ["-t"]; |
|
|
auto opts = [opt::optmulti("t")]; |
|
|
@@ -375,6 +406,7 @@ fn test_optmulti_short_no_arg() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_optmulti_short_multi() { |
|
|
auto args = ["-t", "20", "-t", "30"]; |
|
|
auto opts = [opt::optmulti("t")]; |
|
|
@@ -390,6 +422,7 @@ fn test_optmulti_short_multi() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_unrecognized_option_long() { |
|
|
auto args = ["--untest"]; |
|
|
auto opts = [opt::optmulti("t")]; |
|
|
@@ -400,6 +433,7 @@ fn test_unrecognized_option_long() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_unrecognized_option_short() { |
|
|
auto args = ["-t"]; |
|
|
auto opts = [opt::optmulti("test")]; |
|
|
@@ -410,6 +444,7 @@ fn test_unrecognized_option_short() { |
|
|
} |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_combined() { |
|
|
auto args = |
|
|
["prog", "free1", "-s", "20", "free2", "--flag", "--long=30", "-f", |
|
|
@@ -435,40 +470,3 @@ fn test_combined() { |
|
|
} |
|
|
} |
|
|
|
|
|
fn main() { |
|
|
test_reqopt_long(); |
|
|
test_reqopt_long_missing(); |
|
|
test_reqopt_long_no_arg(); |
|
|
test_reqopt_long_multi(); |
|
|
test_reqopt_short(); |
|
|
test_reqopt_short_missing(); |
|
|
test_reqopt_short_no_arg(); |
|
|
test_reqopt_short_multi(); |
|
|
test_optopt_long(); |
|
|
test_optopt_long_missing(); |
|
|
test_optopt_long_no_arg(); |
|
|
test_optopt_long_multi(); |
|
|
test_optopt_short(); |
|
|
test_optopt_short_missing(); |
|
|
test_optopt_short_no_arg(); |
|
|
test_optopt_short_multi(); |
|
|
test_optflag_long(); |
|
|
test_optflag_long_missing(); |
|
|
test_optflag_long_arg(); |
|
|
test_optflag_long_multi(); |
|
|
test_optflag_short(); |
|
|
test_optflag_short_missing(); |
|
|
test_optflag_short_arg(); |
|
|
test_optflag_short_multi(); |
|
|
test_optmulti_long(); |
|
|
test_optmulti_long_missing(); |
|
|
test_optmulti_long_no_arg(); |
|
|
test_optmulti_long_multi(); |
|
|
test_optmulti_short(); |
|
|
test_optmulti_short_missing(); |
|
|
test_optmulti_short_no_arg(); |
|
|
test_optmulti_short_multi(); |
|
|
test_unrecognized_option_long(); |
|
|
test_unrecognized_option_short(); |
|
|
test_combined(); |
|
|
}
|