Skip to content

Commit f926cd3

Browse files
authored
Rollup merge of rust-lang#78538 - ssomers:btree_testing_rng, r=Mark-Simulacrum
BTreeMap: document a curious assumption in test cases r? `@Mark-Simulacrum`
2 parents 03eec1d + be01d54 commit f926cd3

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

library/alloc/src/collections/btree/map/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,6 +1686,7 @@ create_append_test!(test_append_239, 239);
16861686
create_append_test!(test_append_1700, 1700);
16871687

16881688
fn rand_data(len: usize) -> Vec<(u32, u32)> {
1689+
assert!(len * 2 <= 70029); // from that point on numbers repeat
16891690
let mut rng = DeterministicRng::new();
16901691
Vec::from_iter((0..len).map(|_| (rng.next(), rng.next())))
16911692
}

library/alloc/src/collections/btree/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ impl DeterministicRng {
4949
DeterministicRng { x: 0x193a6754, y: 0xa8a7d469, z: 0x97830e05, w: 0x113ba7bb }
5050
}
5151

52+
/// Guarantees that the first 70029 results are unique.
5253
fn next(&mut self) -> u32 {
5354
let x = self.x;
5455
let t = x ^ (x << 11);

library/alloc/src/collections/btree/set/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@ fn test_first_last() {
687687
}
688688

689689
fn rand_data(len: usize) -> Vec<u32> {
690+
assert!(len <= 70029); // from that point on numbers repeat
690691
let mut rng = DeterministicRng::new();
691692
Vec::from_iter((0..len).map(|_| rng.next()))
692693
}

0 commit comments

Comments
 (0)