@@ -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// Minimum number of elements to insert, to guarantee a tree with 2 levels,
2123// i.e., a tree who's root is an internal node at height 1, with edges to leaf nodes.
2224// 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;
2729// It's not the minimum size: removing an element from such a tree does not always reduce height.
2830const MIN_INSERTS_HEIGHT_2 : usize = 89 ;
2931
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+
3038// Gathers all references from a mutable iterator and makes sure Miri notices if
3139// using them is dangerous.
3240fn test_all_refs < ' a , T : ' a > ( dummy : & mut T , iter : impl Iterator < Item = & ' a mut T > ) {
@@ -169,6 +177,26 @@ fn test_levels() {
169177 // - 5 elements in right child's last grandchild
170178 assert_eq ! ( map. height( ) , Some ( 2 ) ) ;
171179 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 ) ;
172200}
173201
174202// Ensures the testing infrastructure usually notices order violations.
0 commit comments