test(client): cover timing validation boundaries
This commit is contained in:
1 parent
2c75e08e30
commit
b8d16f3d18
2 files changed
+124
No files matched your search
@@ -85,6 +85,54 @@ fn params_from_config_encodes_continuous_duration_as_zero() {
|
||||
assert_eq!(params_from_config(&config).unwrap().duration_ns, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn params_from_config_rejects_zero_finite_duration() {
|
||||
let config = ClientConfig {
|
||||
duration: Some(Duration::ZERO),
|
||||
..ClientConfig::default()
|
||||
};
|
||||
assert!(matches!(
|
||||
params_from_config(&config),
|
||||
Err(ClientError::InvalidConfig { reason })
|
||||
if reason == "duration must be greater than zero; use None for continuous mode"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn params_from_config_rejects_zero_interval() {
|
||||
let config = ClientConfig {
|
||||
interval: Duration::ZERO,
|
||||
..ClientConfig::default()
|
||||
};
|
||||
assert!(matches!(
|
||||
params_from_config(&config),
|
||||
Err(ClientError::InvalidConfig { reason }) if reason == "interval must be greater than zero"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn params_from_config_rejects_nanosecond_encoding_overflow_as_invalid_config() {
|
||||
let config = ClientConfig {
|
||||
duration: Some(Duration::from_nanos(i64::MAX as u64) + Duration::from_nanos(1)),
|
||||
..ClientConfig::default()
|
||||
};
|
||||
assert!(matches!(
|
||||
params_from_config(&config),
|
||||
Err(ClientError::InvalidConfig { reason })
|
||||
if reason == "duration is too large to encode as nanoseconds"
|
||||
));
|
||||
|
||||
let config = ClientConfig {
|
||||
interval: Duration::from_nanos(i64::MAX as u64) + Duration::from_nanos(1),
|
||||
..ClientConfig::default()
|
||||
};
|
||||
assert!(matches!(
|
||||
params_from_config(&config),
|
||||
Err(ClientError::InvalidConfig { reason })
|
||||
if reason == "interval is too large to encode as nanoseconds"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn params_from_config_accepts_max_dscp_codepoint() {
|
||||
let config = ClientConfig {
|
||||
|
||||
Reference in new issue
Block a user