@@ -17,6 +17,8 @@ use std::ops::RangeBounds;
1717use std:: panic:: { catch_unwind, AssertUnwindSafe } ;
1818use std:: sync:: atomic:: { AtomicUsize , Ordering :: SeqCst } ;
1919
20+ mod split_off_range;
21+
2022// Capacity of a tree with a single level,
2123// i.e., a tree who's root is a leaf node at height 0.
2224const NODE_CAPACITY : usize = node:: CAPACITY ;
@@ -31,6 +33,12 @@ const MIN_INSERTS_HEIGHT_1: usize = NODE_CAPACITY + 1;
3133// It's not the minimum size: removing an element from such a tree does not always reduce height.
3234const MIN_INSERTS_HEIGHT_2 : usize = 89 ;
3335
36+ // Like MIN_INSERTS_HEIGHT_2, with an additional internal level.
37+ const MIN_INSERTS_HEIGHT_3 : usize = 628 ;
38+
39+ // Like MIN_INSERTS_HEIGHT_3, with an additional internal level.
40+ const MIN_INSERTS_HEIGHT_4 : usize = 4401 ;
41+
3442// Gathers all references from a mutable iterator and makes sure Miri notices if
3543// using them is dangerous.
3644fn test_all_refs < ' a , T : ' a > ( dummy : & mut T , iter : impl Iterator < Item = & ' a mut T > ) {
@@ -173,6 +181,26 @@ fn test_levels() {
173181 // - 5 elements in right child's last grandchild
174182 assert_eq ! ( map. height( ) , Some ( 2 ) ) ;
175183 assert_eq ! ( map. len( ) , MIN_INSERTS_HEIGHT_2 , "{}" , map. dump_keys( ) ) ;
184+
185+ if cfg ! ( miri) {
186+ // Miri is too slow
187+ return ;
188+ }
189+ while map. height ( ) == Some ( 2 ) {
190+ let last_key = * map. last_key_value ( ) . unwrap ( ) . 0 ;
191+ map. insert ( last_key + 1 , ( ) ) ;
192+ }
193+ map. check ( ) ;
194+ assert_eq ! ( map. height( ) , Some ( 3 ) ) ;
195+ assert_eq ! ( map. len( ) , MIN_INSERTS_HEIGHT_3 ) ;
196+
197+ while map. height ( ) == Some ( 3 ) {
198+ let last_key = * map. last_key_value ( ) . unwrap ( ) . 0 ;
199+ map. insert ( last_key + 1 , ( ) ) ;
200+ }
201+ map. check ( ) ;
202+ assert_eq ! ( map. height( ) , Some ( 4 ) ) ;
203+ assert_eq ! ( map. len( ) , MIN_INSERTS_HEIGHT_4 ) ;
176204}
177205
178206// Ensures the testing infrastructure usually notices order violations.
0 commit comments