use super::*;
#[test]
fn _0001() {
eq_diag(
"short option must be a letter or digit, but '-$' found",
r#"
error: short option must be a letter or digit, but '-$' found
"#,
Clar::new(APP).options([ClarOption::short("color", '$')]).resolve(EMPTY_INPUT).unwrap_err(),
);
}
#[test]
fn _0002() {
eq_diag(
"long option must contain letters, digits or hyphens but '--colo®' found",
r#"
error: long option must contain letters, digits or hyphens but '--colo®' found
"#,
Clar::new(APP).options([ClarOption::long("color", "colo®")]).resolve(EMPTY_INPUT).unwrap_err(),
);
}
#[test]
fn _0003() {
let matches = Clar::new(APP)
.commands([ClarCommand::new("a").help("A").help_long("ALPHA")])
.resolve(EMPTY_INPUT)
.unwrap();
eq_text(
r#"
A
Usage: clars a
"#,
matches.get_help_command("a"),
);
eq_text(
r#"
A
Usage: clars a
"#,
matches.get_help_long_command("a"),
);
eq_text(
r#"
error: command 'b' is not defined"#,
matches.get_help_command("b"),
);
eq_text(
r#"
error: command 'b' is not defined"#,
matches.get_help_long_command("b"),
);
}
#[test]
fn _0004() {
let matches = Clar::new(APP)
.options([ClarOption::short("color", 'c').help("C").help_long("Coloring")])
.resolve(EMPTY_INPUT)
.unwrap();
eq_text(r#"error: command 'a' is not defined"#, matches.get_help_command("a"));
eq_text(r#"error: command 'a' is not defined"#, matches.get_help_long_command("a"));
}
#[test]
fn _0005() {
eq_diag(
"short option must be a letter or digit, but '-$' found",
r#"
error: short option must be a letter or digit, but '-$' found
"#,
Clar::new(APP)
.commands([ClarCommand::new("a").options([ClarOption::short("color", '$')])])
.resolve(EMPTY_INPUT)
.unwrap_err(),
);
}
#[test]
fn _0006() {
eq_diag(
"option '-c' can occur at most 1 time, found 2",
r#"
error: option '-c' can occur at most 1 time, found 2
Usage: clars [OPTIONS]
"#,
Clar::new(APP).options([ClarOption::short("color", 'c')]).resolve(["-c", "-c"]).unwrap_err(),
);
}
#[test]
fn _0007() {
eq_diag(
"option '--color' can occur at most 1 time, found 2",
r#"
error: option '--color' can occur at most 1 time, found 2
Usage: clars [OPTIONS]
"#,
Clar::new(APP)
.options([ClarOption::long("color", "color")])
.resolve(["--color", "--color"])
.unwrap_err(),
);
}
#[test]
fn _0008() {
eq_diag(
"option '--color' can occur at most 1 time, found 2",
r#"
error: option '--color' can occur at most 1 time, found 2
Usage: clars [OPTIONS]
"#,
Clar::new(APP)
.options([ClarOption::new("color", 'c', "color")])
.resolve(["-c", "--color"])
.unwrap_err(),
);
}
#[test]
fn _0009() {
eq_diag(
"option '-c' can occur at most 1 time, found 2",
r#"
error: option '-c' can occur at most 1 time, found 2
Usage: clars [OPTIONS]
"#,
Clar::new(APP).options([ClarOption::short("color", 'c')]).resolve(["-c", "-c"]).unwrap_err(),
);
}
#[test]
fn _0010() {
eq_diag(
"option '--color' can occur at most 1 time, found 2",
r#"
error: option '--color' can occur at most 1 time, found 2
Usage: clars [OPTIONS]
"#,
Clar::new(APP)
.options([ClarOption::long("color", "color")])
.resolve(["--color", "--color"])
.unwrap_err(),
);
}
#[test]
fn _0011() {
eq_diag(
"option '-c' can occur at most 5 times, found 7",
r#"
error: option '-c' can occur at most 5 times, found 7
Usage: clars [OPTIONS]
"#,
Clar::new(APP)
.options([ClarOption::short("color", 'c').max_occurrences(5)])
.resolve(["-c", "-c", "-c", "-c", "-c", "-c", "-c"])
.unwrap_err(),
);
}