File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed
test/Libraries/CoreNodesTests Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 1
- using System ;
1
+ using System ;
2
2
using System . Collections ;
3
3
using System . Collections . Generic ;
4
4
using System . Linq ;
@@ -1346,7 +1346,7 @@ public static IList AllIndicesOf(IList list, object item)
1346
1346
if ( list == null )
1347
1347
return new List < int > { } ;
1348
1348
1349
- var indices = Enumerable . Range ( 0 , list . Count ) . Where ( i => list [ i ] . Equals ( item ) ) . ToList ( ) ;
1349
+ var indices = Enumerable . Range ( 0 , list . Count ) . Where ( i => list [ i ] != null ? list [ i ] . Equals ( item ) : item == null ) . ToList ( ) ;
1350
1350
return indices ;
1351
1351
}
1352
1352
Original file line number Diff line number Diff line change 1
- using System ;
1
+ using System ;
2
2
using System . Collections ;
3
3
using System . Collections . Generic ;
4
4
using System . Linq ;
@@ -948,6 +948,25 @@ public static void AllIndicesOf()
948
948
Assert . IsEmpty ( indices ) ;
949
949
}
950
950
951
+ [ Test ]
952
+ [ Category ( "UnitTests" ) ]
953
+ public static void AllIndicesOfNullTest ( )
954
+ {
955
+ var input = new List < object > { true , false , null } ;
956
+
957
+ var indices = List . AllIndicesOf ( input , true ) ;
958
+ Assert . True ( indices . Count == 1 ) ;
959
+ Assert . AreEqual ( 0 , indices [ 0 ] ) ;
960
+
961
+ indices = List . AllIndicesOf ( input , false ) ;
962
+ Assert . True ( indices . Count == 1 ) ;
963
+ Assert . AreEqual ( 1 , indices [ 0 ] ) ;
964
+
965
+ indices = List . AllIndicesOf ( input , null ) ;
966
+ Assert . True ( indices . Count == 1 ) ;
967
+ Assert . AreEqual ( 2 , indices [ 0 ] ) ;
968
+ }
969
+
951
970
[ Test ]
952
971
[ Category ( "UnitTests" ) ]
953
972
public static void CleanNullsPreserveIndices ( )
You can’t perform that action at this time.
0 commit comments