Skip to content

Commit 6e65a99

Browse files
authored
test: corrected some test cases (#52)
1 parent a589745 commit 6e65a99

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

src/help/mod.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ mod tests_of_help {
970970
}
971971

972972
#[test]
973-
fn add_opts_with_margins_both_of_new_method_and_add_text_with_margins() {
973+
fn add_opts_with_margins_by_constructor_and_add_text_with_margins() {
974974
use crate::OptCfgParam::*;
975975

976976
let cols = linebreak::term_cols();
@@ -1160,14 +1160,17 @@ mod tests_of_help {
11601160

11611161
let mut help = Help::new();
11621162
help.add_opts(&[
1163-
OptCfg::with([names(&["foo-bar"]), desc("description")]),
1164-
OptCfg::with([names(&["*"]), desc("any option")]),
1163+
OptCfg::with([store_key("foo"), desc("description")]),
1164+
OptCfg::with([store_key("bar"), names(&["", ""]), desc("description")]),
11651165
]);
11661166

11671167
let mut iter = help.iter();
11681168

11691169
let line = iter.next();
1170-
assert_eq!(line, Some("--foo-bar description".to_string()));
1170+
assert_eq!(line, Some("--foo description".to_string()));
1171+
1172+
let line = iter.next();
1173+
assert_eq!(line, Some(" --bar description".to_string()));
11711174

11721175
let line = iter.next();
11731176
assert_eq!(line, None);
@@ -1212,7 +1215,7 @@ mod tests_of_help {
12121215
}
12131216

12141217
#[test]
1215-
fn add_text_with_indent_if_indent_is_longer_than_line_width() {
1218+
fn add_opts_with_indent_if_indent_is_longer_than_line_width() {
12161219
use crate::OptCfgParam::*;
12171220

12181221
let cols = linebreak::term_cols();
@@ -1236,7 +1239,7 @@ mod tests_of_help {
12361239
}
12371240

12381241
#[test]
1239-
fn add_text_with_margins_if_sum_of_margins_are_equal_to_line_width() {
1242+
fn add_opts_with_margins_if_sum_of_margins_are_equal_to_line_width() {
12401243
use crate::OptCfgParam::*;
12411244

12421245
let cols = linebreak::term_cols();

src/parse/parse_for.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,11 @@ mod tests_of_make_opt_cfgs_for {
924924
#[opt(cfg = "f64=7.89", desc = "The description of f64_val", arg = "<n>")]
925925
f64_val: f64,
926926

927-
#[opt(cfg = "ss=[A,B,C]", desc = "The description of s_arr", arg = "<s>")]
927+
#[opt(
928+
cfg = "ss=/[A,a/B,b/C,c]",
929+
desc = "The description of s_arr",
930+
arg = "<s>"
931+
)]
928932
s_arr: Vec<String>,
929933

930934
#[opt(cfg = "ii8=[-1,2,-3]", desc = "The description of i8_arr", arg = "<n>")]
@@ -1050,7 +1054,7 @@ mod tests_of_make_opt_cfgs_for {
10501054
assert_eq!(store.f64_val, 7.89);
10511055
assert_eq!(
10521056
store.s_arr,
1053-
vec!["A".to_string(), "B".to_string(), "C".to_string()]
1057+
vec!["A,a".to_string(), "B,b".to_string(), "C,c".to_string()]
10541058
);
10551059
assert_eq!(store.i8_arr, vec![-1, 2, -3]);
10561060
assert_eq!(store.i16_arr, vec![2, -3, 4]);
@@ -1218,7 +1222,11 @@ mod tests_of_make_opt_cfgs_for {
12181222
assert_eq!(cfg.is_array, true);
12191223
assert_eq!(
12201224
cfg.defaults,
1221-
Some(vec!["A".to_string(), "B".to_string(), "C".to_string()])
1225+
Some(vec![
1226+
"A,a".to_string(),
1227+
"B,b".to_string(),
1228+
"C,c".to_string()
1229+
])
12221230
);
12231231
assert_eq!(cfg.desc, "The description of s_arr".to_string());
12241232
assert_eq!(cfg.arg_in_help, "<s>".to_string());

tests/help_test.rs

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ mod tests_of_print_help {
2323
store_key("fail"),
2424
names(&["f", "fail"]),
2525
desc("Fail fast with no output on HTTP errors"),
26-
arg_in_help("<data>"),
2726
]),
2827
cliargs::OptCfg::with([
2928
store_key("help"),

0 commit comments

Comments
 (0)