File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -1346,4 +1346,29 @@ quickcheck! {
1346
1346
) ;
1347
1347
}
1348
1348
}
1349
+
1350
+ // This should check that if multiple elements are equally minimum or maximum
1351
+ // then `max`, `min` and `minmax` pick the first minimum and the last maximum.
1352
+ // This is to be consistent with `std::iter::max` and `std::iter::min`.
1353
+ fn correct_grouping_map_by_min_max_minmax_order_modulo_key( ) -> ( ) {
1354
+ use itertools:: MinMaxResult ;
1355
+
1356
+ let lookup = ( 0 ..=10 )
1357
+ . into_grouping_map_by( |_| 0 )
1358
+ . max_by( |_, _, _| Ordering :: Equal ) ;
1359
+
1360
+ assert_eq!( lookup[ & 0 ] , 10 ) ;
1361
+
1362
+ let lookup = ( 0 ..=10 )
1363
+ . into_grouping_map_by( |_| 0 )
1364
+ . min_by( |_, _, _| Ordering :: Equal ) ;
1365
+
1366
+ assert_eq!( lookup[ & 0 ] , 0 ) ;
1367
+
1368
+ let lookup = ( 0 ..=10 )
1369
+ . into_grouping_map_by( |_| 0 )
1370
+ . minmax_by( |_, _, _| Ordering :: Equal ) ;
1371
+
1372
+ assert_eq!( lookup[ & 0 ] , MinMaxResult :: MinMax ( 0 , 10 ) ) ;
1373
+ }
1349
1374
}
You can’t perform that action at this time.
0 commit comments