Skip to content

Commit be01d54

Browse files
committed
BTreeMap: document a curious assumption in test cases
1 parent a53fb30 commit be01d54

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
@@ -1661,6 +1661,7 @@ create_append_test!(test_append_239, 239);
16611661
create_append_test!(test_append_1700, 1700);
16621662

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

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
@@ -680,6 +680,7 @@ fn test_first_last() {
680680
}
681681

682682
fn rand_data(len: usize) -> Vec<u32> {
683+
assert!(len <= 70029); // from that point on numbers repeat
683684
let mut rng = DeterministicRng::new();
684685
Vec::from_iter((0..len).map(|_| rng.next()))
685686
}

0 commit comments

Comments
 (0)