summaryrefslogtreecommitdiff
path: root/subprojects/clap/tests/builder/unique_args.rs
blob: 84fbfd7bc74e5a7cb30e79278c40324544dddacc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#[cfg(debug_assertions)]
#[test]
#[should_panic = "Argument names must be unique, but 'arg1' is in use by more than one argument or group"]
fn unique_arg_names() {
    use clap::{Arg, Command};

    let _ = Command::new("some")
        .args([Arg::new("arg1").short('a'), Arg::new("arg1").short('b')])
        .try_get_matches();
}

#[cfg(debug_assertions)]
#[test]
#[should_panic = "Short option names must be unique for each argument, but '-a' is in use by both 'arg1' and 'arg2'"]
fn unique_arg_shorts() {
    use clap::{Arg, Command};

    let _ = Command::new("some")
        .args([Arg::new("arg1").short('a'), Arg::new("arg2").short('a')])
        .try_get_matches();
}

#[cfg(debug_assertions)]
#[test]
#[should_panic = "Long option names must be unique for each argument, but '--long' is in use by both 'arg1' and 'arg2'"]
fn unique_arg_longs() {
    use clap::{Arg, Command};

    let _ = Command::new("some")
        .args([Arg::new("arg1").long("long"), Arg::new("arg2").long("long")])
        .try_get_matches();
}