File tree 1 file changed +32
-0
lines changed
src/libcollectionstest/btree
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -346,6 +346,38 @@ fn test_bad_zst() {
346
346
}
347
347
}
348
348
349
+ #[ test]
350
+ fn test_clone ( ) {
351
+ let mut map = BTreeMap :: new ( ) ;
352
+ let size = 100 ;
353
+ assert_eq ! ( map. len( ) , 0 ) ;
354
+
355
+ for i in 0 ..size {
356
+ assert_eq ! ( map. insert( i, 10 * i) , None ) ;
357
+ assert_eq ! ( map. len( ) , i + 1 ) ;
358
+ assert_eq ! ( map, map. clone( ) ) ;
359
+ }
360
+
361
+ for i in 0 ..size {
362
+ assert_eq ! ( map. insert( i, 100 * i) , Some ( 10 * i) ) ;
363
+ assert_eq ! ( map. len( ) , size) ;
364
+ assert_eq ! ( map, map. clone( ) ) ;
365
+ }
366
+
367
+ for i in 0 ..size/2 {
368
+ assert_eq ! ( map. remove( & ( i* 2 ) ) , Some ( i* 200 ) ) ;
369
+ assert_eq ! ( map. len( ) , size - i - 1 ) ;
370
+ assert_eq ! ( map, map. clone( ) ) ;
371
+ }
372
+
373
+ for i in 0 ..size/2 {
374
+ assert_eq ! ( map. remove( & ( 2 * i) ) , None ) ;
375
+ assert_eq ! ( map. remove( & ( 2 * i+1 ) ) , Some ( i* 200 + 100 ) ) ;
376
+ assert_eq ! ( map. len( ) , size/2 - i - 1 ) ;
377
+ assert_eq ! ( map, map. clone( ) ) ;
378
+ }
379
+ }
380
+
349
381
mod bench {
350
382
use std:: collections:: BTreeMap ;
351
383
use std:: __rand:: { Rng , thread_rng} ;
You can’t perform that action at this time.
0 commit comments