test(cli): consolidate invalid argument parsing tests
This commit is contained in:
1 file changed
+21
-34
+21
-34
@@ -724,13 +724,6 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn rejects_invalid_duration() {
|
|
||||||
assert!(parse(&["--duration", "-1s", "127.0.0.1:2112"]).is_err());
|
|
||||||
assert!(parse(&["--duration", "5", "127.0.0.1:2112"]).is_err());
|
|
||||||
assert!(parse(&["--duration", "1h", "127.0.0.1:2112"]).is_err());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn duration_zero_selects_continuous_config() {
|
fn duration_zero_selects_continuous_config() {
|
||||||
let args = parse(&["--duration", "0", "127.0.0.1:2112"]).unwrap();
|
let args = parse(&["--duration", "0", "127.0.0.1:2112"]).unwrap();
|
||||||
@@ -739,12 +732,6 @@ mod tests {
|
|||||||
assert_eq!(args.to_client_config().duration, None);
|
assert_eq!(args.to_client_config().duration, None);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn rejects_invalid_interval() {
|
|
||||||
assert!(parse(&["--interval", "0ms", "127.0.0.1:2112"]).is_err());
|
|
||||||
assert!(parse(&["--interval", "-1ms", "127.0.0.1:2112"]).is_err());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parses_output_clock_and_timestamp_modes() {
|
fn parses_output_clock_and_timestamp_modes() {
|
||||||
let args = parse(&[
|
let args = parse(&[
|
||||||
@@ -843,17 +830,6 @@ mod tests {
|
|||||||
assert_eq!(args.to_client_config().server_fill.as_deref(), Some(max));
|
assert_eq!(args.to_client_config().server_fill.as_deref(), Some(max));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn rejects_invalid_server_fill() {
|
|
||||||
assert!(parse(&["--sfill", "", "127.0.0.1:2112"]).is_err());
|
|
||||||
assert!(parse(&[
|
|
||||||
"--sfill",
|
|
||||||
"0123456789abcdef0123456789abcdefx",
|
|
||||||
"127.0.0.1:2112"
|
|
||||||
])
|
|
||||||
.is_err());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn maps_dscp_codepoints() {
|
fn maps_dscp_codepoints() {
|
||||||
for value in ["0", "46", "63"] {
|
for value in ["0", "46", "63"] {
|
||||||
@@ -862,13 +838,6 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn rejects_invalid_dscp_codepoints() {
|
|
||||||
assert!(parse(&["--dscp", "64", "127.0.0.1:2112"]).is_err());
|
|
||||||
assert!(parse(&["--dscp", "-1", "127.0.0.1:2112"]).is_err());
|
|
||||||
assert!(parse(&["--dscp", "abc", "127.0.0.1:2112"]).is_err());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn maps_loose_negotiation() {
|
fn maps_loose_negotiation() {
|
||||||
let args = parse(&["127.0.0.1:2112"]).unwrap();
|
let args = parse(&["127.0.0.1:2112"]).unwrap();
|
||||||
@@ -896,9 +865,27 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn rejects_invalid_length() {
|
fn rejects_invalid_argument_values() {
|
||||||
assert!(parse(&["--length", "-1", "127.0.0.1:2112"]).is_err());
|
for args in [
|
||||||
assert!(parse(&["--length", "65508", "127.0.0.1:2112"]).is_err());
|
&["--duration", "-1s", "127.0.0.1:2112"][..],
|
||||||
|
&["--duration", "5", "127.0.0.1:2112"],
|
||||||
|
&["--duration", "1h", "127.0.0.1:2112"],
|
||||||
|
&["--interval", "0ms", "127.0.0.1:2112"],
|
||||||
|
&["--interval", "-1ms", "127.0.0.1:2112"],
|
||||||
|
&["--sfill", "", "127.0.0.1:2112"],
|
||||||
|
&[
|
||||||
|
"--sfill",
|
||||||
|
"0123456789abcdef0123456789abcdefx",
|
||||||
|
"127.0.0.1:2112",
|
||||||
|
],
|
||||||
|
&["--dscp", "64", "127.0.0.1:2112"],
|
||||||
|
&["--dscp", "-1", "127.0.0.1:2112"],
|
||||||
|
&["--dscp", "abc", "127.0.0.1:2112"],
|
||||||
|
&["--length", "-1", "127.0.0.1:2112"],
|
||||||
|
&["--length", "65508", "127.0.0.1:2112"],
|
||||||
|
] {
|
||||||
|
assert!(parse(args).is_err(), "expected parse failure for {args:?}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in new issue
Block a user