diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:26:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:26:03 +0000 |
commit | 9918693037dce8aa4bb6f08741b6812923486c18 (patch) | |
tree | 21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /vendor/gix-utils/tests/backoff/mod.rs | |
parent | Releasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff) | |
download | rustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip |
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gix-utils/tests/backoff/mod.rs')
-rw-r--r-- | vendor/gix-utils/tests/backoff/mod.rs | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/vendor/gix-utils/tests/backoff/mod.rs b/vendor/gix-utils/tests/backoff/mod.rs deleted file mode 100644 index a84ed7543..000000000 --- a/vendor/gix-utils/tests/backoff/mod.rs +++ /dev/null @@ -1,56 +0,0 @@ -use std::{convert::TryInto, time::Duration}; - -use gix_utils::backoff::Exponential; - -const EXPECTED_TILL_SECOND: &[usize] = &[ - 1usize, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, - 625, 676, 729, 784, 841, 900, 961, 1000, 1000, -]; - -#[test] -fn random_exponential_produces_values_in_the_correct_range() { - let mut num_identities = 0; - for (actual, expected) in Exponential::default_with_random().zip(EXPECTED_TILL_SECOND) { - let actual: usize = actual.as_millis().try_into().unwrap(); - if actual == *expected { - num_identities += 1; - } - assert!( - actual * 1000 >= (expected - 1) * 750, - "value too small: {actual} < {expected}" - ); - assert!( - actual * 1000 <= (expected + 1) * 1250, - "value too big: {actual} > {expected}" - ); - } - assert!( - num_identities < EXPECTED_TILL_SECOND.len(), - "too many untransformed values: {num_identities}" - ); -} - -#[test] -fn how_many_iterations_for_a_second_of_waittime() { - let max = Duration::from_millis(1000); - assert_eq!(Exponential::default().until_no_remaining(max).count(), 14); - assert_eq!( - Exponential::default() - .until_no_remaining(max) - .reduce(|acc, n| acc + n) - .unwrap(), - Duration::from_millis(1015), - "a little overshoot" - ); -} - -#[test] -fn output_with_default_settings() { - assert_eq!( - Exponential::default().take(33).collect::<Vec<_>>(), - EXPECTED_TILL_SECOND - .iter() - .map(|n| Duration::from_millis(*n as u64)) - .collect::<Vec<_>>() - ); -} |