@@ -853,6 +853,8 @@ public void RemoveRange()
853
853
{
854
854
Assert . Throws < ArgumentOutOfRangeException > ( ( ) => s_empty . RemoveRange ( 0 , 0 ) ) ;
855
855
Assert . Throws < NullReferenceException > ( ( ) => s_emptyDefault . RemoveRange ( 0 , 0 ) ) ;
856
+ Assert . Throws < ArgumentOutOfRangeException > ( ( ) => s_emptyDefault . RemoveRange ( - 1 , 0 ) ) ;
857
+ Assert . Throws < NullReferenceException > ( ( ) => s_emptyDefault . RemoveRange ( 0 , - 1 ) ) ;
856
858
Assert . Throws < ArgumentOutOfRangeException > ( ( ) => s_oneElement . RemoveRange ( 1 , 0 ) ) ;
857
859
Assert . Throws < ArgumentOutOfRangeException > ( ( ) => s_empty . RemoveRange ( - 1 , 0 ) ) ;
858
860
Assert . Throws < ArgumentOutOfRangeException > ( ( ) => s_oneElement . RemoveRange ( 0 , 2 ) ) ;
@@ -940,6 +942,35 @@ public void RemoveRangeEnumerableTest()
940
942
Assert . Equal ( new [ ] { 1 , 3 } , listWithDuplicates . RemoveRange ( new [ ] { 2 , 2 , 2 } ) ) ;
941
943
}
942
944
945
+ [ Fact ]
946
+ public void RemoveRangeImmutableArrayTest ( )
947
+ {
948
+ var list = ImmutableArray . Create ( 1 , 2 , 3 ) ;
949
+
950
+ ImmutableArray < int > removed2 = list . RemoveRange ( ImmutableArray . Create ( 2 ) ) ;
951
+ Assert . Equal ( 2 , removed2 . Length ) ;
952
+ Assert . Equal ( new [ ] { 1 , 3 } , removed2 ) ;
953
+
954
+ ImmutableArray < int > removed13 = list . RemoveRange ( ImmutableArray . Create ( 1 , 3 , 5 ) ) ;
955
+ Assert . Equal ( 1 , removed13 . Length ) ;
956
+ Assert . Equal ( new [ ] { 2 } , removed13 ) ;
957
+
958
+ Assert . Equal ( new [ ] { 1 , 3 , 6 , 8 , 9 } , ImmutableArray . CreateRange ( Enumerable . Range ( 1 , 10 ) ) . RemoveRange ( ImmutableArray . Create ( 2 , 4 , 5 , 7 , 10 ) ) ) ;
959
+ Assert . Equal ( new [ ] { 3 , 6 , 8 , 9 } , ImmutableArray . CreateRange ( Enumerable . Range ( 1 , 10 ) ) . RemoveRange ( ImmutableArray . Create ( 1 , 2 , 4 , 5 , 7 , 10 ) ) ) ;
960
+
961
+ Assert . Equal ( list , list . RemoveRange ( ImmutableArray . Create ( 5 ) ) ) ;
962
+ Assert . Equal ( ImmutableArray . Create < int > ( ) , ImmutableArray . Create < int > ( ) . RemoveRange ( ImmutableArray . Create ( 1 ) ) ) ;
963
+
964
+ var listWithDuplicates = ImmutableArray . Create ( 1 , 2 , 2 , 3 ) ;
965
+ Assert . Equal ( new [ ] { 1 , 2 , 3 } , listWithDuplicates . RemoveRange ( ImmutableArray . Create ( 2 ) ) ) ;
966
+ Assert . Equal ( new [ ] { 1 , 3 } , listWithDuplicates . RemoveRange ( ImmutableArray . Create ( 2 , 2 ) ) ) ;
967
+ Assert . Equal ( new [ ] { 1 , 3 } , listWithDuplicates . RemoveRange ( ImmutableArray . Create ( 2 , 2 , 2 ) ) ) ;
968
+
969
+ Assert . Equal ( new [ ] { 2 , 3 } , list . RemoveRange ( ImmutableArray . Create ( 42 ) , EverythingEqual < int > . Default ) ) ;
970
+ Assert . Equal ( new [ ] { 3 } , list . RemoveRange ( ImmutableArray . Create ( 42 , 42 ) , EverythingEqual < int > . Default ) ) ;
971
+ Assert . Equal ( new int [ 0 ] , list . RemoveRange ( ImmutableArray . Create ( 42 , 42 , 42 ) , EverythingEqual < int > . Default ) ) ;
972
+ }
973
+
943
974
[ Fact ]
944
975
public void Replace ( )
945
976
{
0 commit comments