@@ -923,3 +923,94 @@ move_index_oob!(test_move_index_out_of_bounds_0_10, 0, 10);
923
923
move_index_oob ! ( test_move_index_out_of_bounds_0_max, 0 , usize :: MAX ) ;
924
924
move_index_oob ! ( test_move_index_out_of_bounds_10_0, 10 , 0 ) ;
925
925
move_index_oob ! ( test_move_index_out_of_bounds_max_0, usize :: MAX , 0 ) ;
926
+
927
+ #[ test]
928
+ fn disjoint_mut_empty_map ( ) {
929
+ let mut map: RingMap < u32 , u32 > = RingMap :: default ( ) ;
930
+ assert ! ( map. get_disjoint_mut( [ & 0 , & 1 , & 2 , & 3 ] ) . is_none( ) ) ;
931
+ }
932
+
933
+ #[ test]
934
+ fn disjoint_mut_empty_param ( ) {
935
+ let mut map: RingMap < u32 , u32 > = RingMap :: default ( ) ;
936
+ map. insert ( 1 , 10 ) ;
937
+ assert ! ( map. get_disjoint_mut( [ ] as [ & u32 ; 0 ] ) . is_some( ) ) ;
938
+ }
939
+
940
+ #[ test]
941
+ fn disjoint_mut_single_fail ( ) {
942
+ let mut map: RingMap < u32 , u32 > = RingMap :: default ( ) ;
943
+ map. insert ( 1 , 10 ) ;
944
+ assert ! ( map. get_disjoint_mut( [ & 0 ] ) . is_none( ) ) ;
945
+ }
946
+
947
+ #[ test]
948
+ fn disjoint_mut_single_success ( ) {
949
+ let mut map: RingMap < u32 , u32 > = RingMap :: default ( ) ;
950
+ map. insert ( 1 , 10 ) ;
951
+ assert_eq ! ( map. get_disjoint_mut( [ & 1 ] ) , Some ( [ & mut 10 ] ) ) ;
952
+ }
953
+
954
+ #[ test]
955
+ fn disjoint_mut_multi_success ( ) {
956
+ let mut map: RingMap < u32 , u32 > = RingMap :: default ( ) ;
957
+ map. insert ( 1 , 100 ) ;
958
+ map. insert ( 2 , 200 ) ;
959
+ map. insert ( 3 , 300 ) ;
960
+ map. insert ( 4 , 400 ) ;
961
+ assert_eq ! ( map. get_disjoint_mut( [ & 1 , & 2 ] ) , Some ( [ & mut 100 , & mut 200 ] ) ) ;
962
+ assert_eq ! ( map. get_disjoint_mut( [ & 1 , & 3 ] ) , Some ( [ & mut 100 , & mut 300 ] ) ) ;
963
+ assert_eq ! (
964
+ map. get_disjoint_mut( [ & 3 , & 1 , & 4 , & 2 ] ) ,
965
+ Some ( [ & mut 300 , & mut 100 , & mut 400 , & mut 200 ] )
966
+ ) ;
967
+ }
968
+
969
+ #[ test]
970
+ fn disjoint_mut_multi_success_unsized_key ( ) {
971
+ let mut map: RingMap < & ' static str , u32 > = RingMap :: default ( ) ;
972
+ map. insert ( "1" , 100 ) ;
973
+ map. insert ( "2" , 200 ) ;
974
+ map. insert ( "3" , 300 ) ;
975
+ map. insert ( "4" , 400 ) ;
976
+ assert_eq ! ( map. get_disjoint_mut( [ "1" , "2" ] ) , Some ( [ & mut 100 , & mut 200 ] ) ) ;
977
+ assert_eq ! ( map. get_disjoint_mut( [ "1" , "3" ] ) , Some ( [ & mut 100 , & mut 300 ] ) ) ;
978
+ assert_eq ! (
979
+ map. get_disjoint_mut( [ "3" , "1" , "4" , "2" ] ) ,
980
+ Some ( [ & mut 300 , & mut 100 , & mut 400 , & mut 200 ] )
981
+ ) ;
982
+ }
983
+
984
+ #[ test]
985
+ fn disjoint_mut_multi_fail_missing ( ) {
986
+ let mut map: RingMap < u32 , u32 > = RingMap :: default ( ) ;
987
+ map. insert ( 1 , 10 ) ;
988
+ map. insert ( 1123 , 100 ) ;
989
+ map. insert ( 321 , 20 ) ;
990
+ map. insert ( 1337 , 30 ) ;
991
+ assert_eq ! ( map. get_disjoint_mut( [ & 121 , & 1123 ] ) , None ) ;
992
+ assert_eq ! ( map. get_disjoint_mut( [ & 1 , & 1337 , & 56 ] ) , None ) ;
993
+ assert_eq ! ( map. get_disjoint_mut( [ & 1337 , & 123 , & 321 , & 1 , & 1123 ] ) , None ) ;
994
+ }
995
+
996
+ #[ test]
997
+ fn disjoint_mut_multi_fail_duplicate ( ) {
998
+ let mut map: RingMap < u32 , u32 > = RingMap :: default ( ) ;
999
+ map. insert ( 1 , 10 ) ;
1000
+ map. insert ( 1123 , 100 ) ;
1001
+ map. insert ( 321 , 20 ) ;
1002
+ map. insert ( 1337 , 30 ) ;
1003
+ assert_eq ! ( map. get_disjoint_mut( [ & 1 , & 1 ] ) , None ) ;
1004
+ assert_eq ! (
1005
+ map. get_disjoint_mut( [ & 1337 , & 123 , & 321 , & 1337 , & 1 , & 1123 ] ) ,
1006
+ None
1007
+ ) ;
1008
+ }
1009
+
1010
+ #[ test]
1011
+ fn many_index_mut_fail_oob ( ) {
1012
+ let mut map: RingMap < u32 , u32 > = RingMap :: default ( ) ;
1013
+ map. insert ( 1 , 10 ) ;
1014
+ map. insert ( 321 , 20 ) ;
1015
+ assert_eq ! ( map. get_disjoint_indices_mut( [ 1 , 3 ] ) , None ) ;
1016
+ }
0 commit comments