@@ -17,6 +17,8 @@ use std::ops::RangeBounds;
17
17
use std:: panic:: { catch_unwind, AssertUnwindSafe } ;
18
18
use std:: sync:: atomic:: { AtomicUsize , Ordering :: SeqCst } ;
19
19
20
+ mod split_off_range;
21
+
20
22
// Minimum number of elements to insert, to guarantee a tree with 2 levels,
21
23
// i.e., a tree who's root is an internal node at height 1, with edges to leaf nodes.
22
24
// It's not the minimum size: removing an element from such a tree does not always reduce height.
@@ -27,6 +29,12 @@ const MIN_INSERTS_HEIGHT_1: usize = node::CAPACITY + 1;
27
29
// It's not the minimum size: removing an element from such a tree does not always reduce height.
28
30
const MIN_INSERTS_HEIGHT_2 : usize = 89 ;
29
31
32
+ // Like MIN_INSERTS_HEIGHT_2, with an additional internal level.
33
+ const MIN_INSERTS_HEIGHT_3 : usize = 628 ;
34
+
35
+ // Like MIN_INSERTS_HEIGHT_3, with an additional internal level.
36
+ const MIN_INSERTS_HEIGHT_4 : usize = 4401 ;
37
+
30
38
// Gathers all references from a mutable iterator and makes sure Miri notices if
31
39
// using them is dangerous.
32
40
fn test_all_refs < ' a , T : ' a > ( dummy : & mut T , iter : impl Iterator < Item = & ' a mut T > ) {
@@ -169,6 +177,26 @@ fn test_levels() {
169
177
// - 5 elements in right child's last grandchild
170
178
assert_eq ! ( map. height( ) , Some ( 2 ) ) ;
171
179
assert_eq ! ( map. len( ) , MIN_INSERTS_HEIGHT_2 , "{}" , map. dump_keys( ) ) ;
180
+
181
+ if cfg ! ( miri) {
182
+ // Miri is too slow
183
+ return ;
184
+ }
185
+ while map. height ( ) == Some ( 2 ) {
186
+ let last_key = * map. last_key_value ( ) . unwrap ( ) . 0 ;
187
+ map. insert ( last_key + 1 , ( ) ) ;
188
+ }
189
+ map. check ( ) ;
190
+ assert_eq ! ( map. height( ) , Some ( 3 ) ) ;
191
+ assert_eq ! ( map. len( ) , MIN_INSERTS_HEIGHT_3 ) ;
192
+
193
+ while map. height ( ) == Some ( 3 ) {
194
+ let last_key = * map. last_key_value ( ) . unwrap ( ) . 0 ;
195
+ map. insert ( last_key + 1 , ( ) ) ;
196
+ }
197
+ map. check ( ) ;
198
+ assert_eq ! ( map. height( ) , Some ( 4 ) ) ;
199
+ assert_eq ! ( map. len( ) , MIN_INSERTS_HEIGHT_4 ) ;
172
200
}
173
201
174
202
// Ensures the testing infrastructure usually notices order violations.
0 commit comments