Skip to content

Commit

Permalink
Add unit test for ConstantInterval
Browse files Browse the repository at this point in the history
  • Loading branch information
dlon committed Sep 19, 2023
1 parent ed44842 commit b509134
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions talpid-core/src/future_retry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,22 @@ fn apply_jitter(duration: Duration, jitter: f64) -> Duration {
mod test {
use super::*;

#[test]
fn test_constant_interval() {
let mut ivl = ConstantInterval::new(Duration::from_secs(2), Some(3));

assert_eq!(ivl.next(), Some(Duration::from_secs(2)));
assert_eq!(ivl.next(), Some(Duration::from_secs(2)));
assert_eq!(ivl.next(), Some(Duration::from_secs(2)));
assert_eq!(ivl.next(), None);
}

#[test]
fn test_constant_interval_no_max() {
let mut ivl = ConstantInterval::new(Duration::from_secs(2), None);
assert_eq!(ivl.next(), Some(Duration::from_secs(2)));
}

#[test]
fn test_exponential_backoff() {
let mut backoff = ExponentialBackoff::new(Duration::from_secs(2), 3);
Expand Down

0 comments on commit b509134

Please sign in to comment.