11// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
22// Licensed under the MIT License. See LICENSE in the project root for license information.
33
4- #nullable disable
5-
64namespace TunnelVisionLabs . Collections . Trees . Test . Immutable
75{
86 using System ;
@@ -68,7 +66,7 @@ private static void TestIListInterfaceImpl(IList list, bool supportsNullValues)
6866 list . Remove ( "Text" ) ;
6967 Assert . Equal ( originalCount , list . Count ) ;
7068
71- object removedItem = list [ 0 ] ;
69+ object ? removedItem = list [ 0 ] ;
7270 list . Remove ( list [ 0 ] ) ;
7371 Assert . Equal ( originalCount - 1 , list . Count ) ;
7472 Assert . True ( list . Contains ( removedItem ) ) ;
@@ -141,7 +139,7 @@ private static void TestICollectionInterfaceImpl(ICollection collection, bool is
141139 Assert . Same ( collection . SyncRoot , collection . SyncRoot ) ;
142140 }
143141
144- Assert . Throws < ArgumentNullException > ( "array" , ( ) => collection . CopyTo ( null , 0 ) ) ;
142+ Assert . Throws < ArgumentNullException > ( "array" , ( ) => collection . CopyTo ( null ! , 0 ) ) ;
145143 Assert . Throws < ArgumentException > ( ( ) => collection . CopyTo ( new int [ collection . Count , 1 ] , 0 ) ) ;
146144
147145 void CopyToArrayWithNonZeroLowerBound ( ) => collection . CopyTo ( Array . CreateInstance ( typeof ( int ) , lengths : new [ ] { collection . Count } , lowerBounds : new [ ] { 1 } ) , 0 ) ;
@@ -224,40 +222,40 @@ private static void TestICollectionTInterfaceImpl<T>(ICollection<T> collection,
224222 var copy = new T [ collection . Count ] ;
225223
226224 Assert . Throws < ArgumentOutOfRangeException > ( ( ) => collection . CopyTo ( copy , - 1 ) ) ;
227- Assert . All ( copy , item => Assert . Equal ( default , item ) ) ;
225+ Assert . All ( copy , item => Assert . Equal ( default ! , item ) ) ;
228226 Assert . Throws < ArgumentOutOfRangeException > ( ( ) => collection . CopyTo ( copy , 1 ) ) ;
229- Assert . All ( copy , item => Assert . Equal ( default , item ) ) ;
227+ Assert . All ( copy , item => Assert . Equal ( default ! , item ) ) ;
230228
231229 collection . CopyTo ( copy , 0 ) ;
232- Assert . Equal < object > ( 600 , copy [ 0 ] ) ;
233- Assert . Equal < object > ( 601 , copy [ 1 ] ) ;
230+ Assert . Equal < object ? > ( 600 , copy [ 0 ] ) ;
231+ Assert . Equal < object ? > ( 601 , copy [ 1 ] ) ;
234232
235233 copy = new T [ collection . Count + 2 ] ;
236234 collection . CopyTo ( copy , 1 ) ;
237- Assert . Equal ( default , copy [ 0 ] ) ;
238- Assert . Equal < object > ( 600 , copy [ 1 ] ) ;
239- Assert . Equal < object > ( 601 , copy [ 2 ] ) ;
240- Assert . Equal ( default , copy [ 3 ] ) ;
235+ Assert . Equal ( default ! , copy [ 0 ] ) ;
236+ Assert . Equal < object ? > ( 600 , copy [ 1 ] ) ;
237+ Assert . Equal < object ? > ( 601 , copy [ 2 ] ) ;
238+ Assert . Equal ( default ! , copy [ 3 ] ) ;
241239 }
242240 else
243241 {
244242 var copy = new T [ collection . Count ] ;
245243
246244 Assert . Throws < ArgumentOutOfRangeException > ( ( ) => collection . CopyTo ( copy , - 1 ) ) ;
247- Assert . All ( copy , item => Assert . Equal ( default , item ) ) ;
245+ Assert . All ( copy , item => Assert . Equal ( default ! , item ) ) ;
248246 Assert . Throws < ArgumentOutOfRangeException > ( ( ) => collection . CopyTo ( copy , 1 ) ) ;
249- Assert . All ( copy , item => Assert . Equal ( default , item ) ) ;
247+ Assert . All ( copy , item => Assert . Equal ( default ! , item ) ) ;
250248
251249 collection . CopyTo ( copy , 0 ) ;
252- Assert . Equal < object > ( 600 , copy [ 0 ] ) ;
253- Assert . Equal < object > ( 601 , copy [ 1 ] ) ;
250+ Assert . Equal < object ? > ( 600 , copy [ 0 ] ) ;
251+ Assert . Equal < object ? > ( 601 , copy [ 1 ] ) ;
254252
255253 copy = new T [ collection . Count + 2 ] ;
256254 collection . CopyTo ( copy , 1 ) ;
257- Assert . Equal ( default , copy [ 0 ] ) ;
258- Assert . Equal < object > ( 600 , copy [ 1 ] ) ;
259- Assert . Equal < object > ( 601 , copy [ 2 ] ) ;
260- Assert . Equal ( default , copy [ 3 ] ) ;
255+ Assert . Equal ( default ! , copy [ 0 ] ) ;
256+ Assert . Equal < object ? > ( 600 , copy [ 1 ] ) ;
257+ Assert . Equal < object ? > ( 601 , copy [ 2 ] ) ;
258+ Assert . Equal ( default ! , copy [ 3 ] ) ;
261259 }
262260 }
263261
@@ -282,8 +280,8 @@ public void TestIndexer()
282280 public void TestCopyToValidation ( )
283281 {
284282 ImmutableTreeList < int > . Builder list = ImmutableTreeList . CreateRange ( Enumerable . Range ( 0 , 10 ) ) . ToBuilder ( ) ;
285- Assert . Throws < ArgumentNullException > ( "array" , ( ) => list . CopyTo ( null ) ) ;
286- Assert . Throws < ArgumentNullException > ( "array" , ( ) => list . CopyTo ( 0 , null , 0 , list . Count ) ) ;
283+ Assert . Throws < ArgumentNullException > ( "array" , ( ) => list . CopyTo ( null ! ) ) ;
284+ Assert . Throws < ArgumentNullException > ( "array" , ( ) => list . CopyTo ( 0 , null ! , 0 , list . Count ) ) ;
287285 Assert . Throws < ArgumentOutOfRangeException > ( "index" , ( ) => list . CopyTo ( - 1 , new int [ list . Count ] , 0 , list . Count ) ) ;
288286 Assert . Throws < ArgumentOutOfRangeException > ( "arrayIndex" , ( ) => list . CopyTo ( 0 , new int [ list . Count ] , - 1 , list . Count ) ) ;
289287 Assert . Throws < ArgumentOutOfRangeException > ( "count" , ( ) => list . CopyTo ( 0 , new int [ list . Count ] , 0 , - 1 ) ) ;
@@ -343,7 +341,7 @@ public void TestAddRange()
343341 ImmutableTreeList < int > . Builder list = ImmutableTreeList . CreateBuilder < int > ( ) ;
344342 CollectionAssert . EnumeratorInvalidated ( list , ( ) => list . AddRange ( expected ) ) ;
345343
346- Assert . Throws < ArgumentNullException > ( "collection" , ( ) => list . AddRange ( null ) ) ;
344+ Assert . Throws < ArgumentNullException > ( "collection" , ( ) => list . AddRange ( null ! ) ) ;
347345 CollectionAssert . EnumeratorNotInvalidated ( list , ( ) => list . AddRange ( Enumerable . Empty < int > ( ) ) ) ;
348346
349347 Assert . Equal ( expected . Length , list . Count ) ;
@@ -411,7 +409,7 @@ public void TestInsertRange()
411409 ImmutableTreeList < int > . Builder list = ImmutableTreeList . CreateBuilder < int > ( ) ;
412410 List < int > reference = new List < int > ( ) ;
413411
414- Assert . Throws < ArgumentNullException > ( "collection" , ( ) => list . InsertRange ( 0 , null ) ) ;
412+ Assert . Throws < ArgumentNullException > ( "collection" , ( ) => list . InsertRange ( 0 , null ! ) ) ;
415413 Assert . Throws < ArgumentOutOfRangeException > ( "index" , ( ) => list . InsertRange ( - 1 , Enumerable . Empty < int > ( ) ) ) ;
416414 Assert . Throws < ArgumentOutOfRangeException > ( null , ( ) => list . InsertRange ( 1 , Enumerable . Empty < int > ( ) ) ) ;
417415
@@ -591,9 +589,9 @@ public void TestFindIndex()
591589 reference . Insert ( index , i ) ;
592590 }
593591
594- Assert . Throws < ArgumentNullException > ( ( ) => list . FindIndex ( null ) ) ;
595- Assert . Throws < ArgumentNullException > ( ( ) => list . FindIndex ( 0 , null ) ) ;
596- Assert . Throws < ArgumentNullException > ( ( ) => list . FindIndex ( 0 , 0 , null ) ) ;
592+ Assert . Throws < ArgumentNullException > ( ( ) => list . FindIndex ( null ! ) ) ;
593+ Assert . Throws < ArgumentNullException > ( ( ) => list . FindIndex ( 0 , null ! ) ) ;
594+ Assert . Throws < ArgumentNullException > ( ( ) => list . FindIndex ( 0 , 0 , null ! ) ) ;
597595
598596 Assert . Throws < ArgumentOutOfRangeException > ( ( ) => list . FindIndex ( - 1 , i => true ) ) ;
599597 Assert . Throws < ArgumentOutOfRangeException > ( ( ) => list . FindIndex ( 0 , - 1 , i => true ) ) ;
@@ -632,9 +630,9 @@ public void TestFindLastIndex()
632630 reference . Insert ( index , i ) ;
633631 }
634632
635- Assert . Throws < ArgumentNullException > ( ( ) => list . FindLastIndex ( null ) ) ;
636- Assert . Throws < ArgumentNullException > ( ( ) => list . FindLastIndex ( - 1 , null ) ) ;
637- Assert . Throws < ArgumentNullException > ( ( ) => list . FindLastIndex ( - 1 , 0 , null ) ) ;
633+ Assert . Throws < ArgumentNullException > ( ( ) => list . FindLastIndex ( null ! ) ) ;
634+ Assert . Throws < ArgumentNullException > ( ( ) => list . FindLastIndex ( - 1 , null ! ) ) ;
635+ Assert . Throws < ArgumentNullException > ( ( ) => list . FindLastIndex ( - 1 , 0 , null ! ) ) ;
638636
639637 Assert . Throws < ArgumentOutOfRangeException > ( ( ) => list . FindLastIndex ( list . Count , i => true ) ) ;
640638 Assert . Throws < ArgumentOutOfRangeException > ( ( ) => list . FindLastIndex ( list . Count - 1 , - 1 , i => true ) ) ;
@@ -814,7 +812,7 @@ public void TestSortComparison()
814812 reference . Insert ( index , item ) ;
815813 }
816814
817- Assert . Throws < ArgumentNullException > ( ( ) => list . Sort ( ( Comparison < int > ) null ) ) ;
815+ Assert . Throws < ArgumentNullException > ( ( ) => list . Sort ( ( Comparison < int > ) null ! ) ) ;
818816
819817 Comparison < int > comparison = ( x , y ) => x - y ;
820818 list . Sort ( comparison ) ;
@@ -1073,7 +1071,7 @@ public void TestRemoveValue()
10731071 public void TestRemoveAll ( )
10741072 {
10751073 var list = ImmutableTreeList . CreateRange ( Enumerable . Range ( 0 , 20 ) ) . ToBuilder ( ) ;
1076- Assert . Throws < ArgumentNullException > ( ( ) => list . RemoveAll ( null ) ) ;
1074+ Assert . Throws < ArgumentNullException > ( ( ) => list . RemoveAll ( null ! ) ) ;
10771075
10781076 Assert . Equal ( 10 , list . RemoveAll ( i => ( i % 2 ) == 0 ) ) ;
10791077 Assert . Equal ( new [ ] { 1 , 3 , 5 , 7 , 9 , 11 , 13 , 15 , 17 , 19 } , list ) ;
@@ -1085,7 +1083,7 @@ public void TestRemoveAll()
10851083 public void TestExists ( )
10861084 {
10871085 var list = ImmutableTreeList . CreateRange ( Enumerable . Range ( 0 , 20 ) ) . ToBuilder ( ) ;
1088- Assert . Throws < ArgumentNullException > ( ( ) => list . Exists ( null ) ) ;
1086+ Assert . Throws < ArgumentNullException > ( ( ) => list . Exists ( null ! ) ) ;
10891087
10901088 Assert . False ( list . Exists ( value => value < 0 ) ) ;
10911089 foreach ( var i in list )
@@ -1100,7 +1098,7 @@ public void TestExists()
11001098 public void TestFind ( )
11011099 {
11021100 var list = ImmutableTreeList . CreateRange ( Enumerable . Range ( 1 , 20 ) ) . ToBuilder ( ) ;
1103- Assert . Throws < ArgumentNullException > ( ( ) => list . Find ( null ) ) ;
1101+ Assert . Throws < ArgumentNullException > ( ( ) => list . Find ( null ! ) ) ;
11041102
11051103 Assert . Equal ( 0 , list . Find ( value => value < 0 ) ) ;
11061104 foreach ( var i in list )
@@ -1115,7 +1113,7 @@ public void TestFind()
11151113 public void TestFindAll ( )
11161114 {
11171115 var list = ImmutableTreeList . CreateRange ( Enumerable . Range ( 0 , 20 ) ) . ToBuilder ( ) ;
1118- Assert . Throws < ArgumentNullException > ( ( ) => list . FindAll ( null ) ) ;
1116+ Assert . Throws < ArgumentNullException > ( ( ) => list . FindAll ( null ! ) ) ;
11191117
11201118 ImmutableTreeList < int > found = list . FindAll ( i => ( i % 2 ) == 0 ) ;
11211119
@@ -1131,7 +1129,7 @@ public void TestFindLast()
11311129 {
11321130 var list = ImmutableTreeList . CreateRange ( Enumerable . Range ( 1 , 20 ) ) . ToBuilder ( ) ;
11331131 var reference = new List < int > ( Enumerable . Range ( 1 , 20 ) ) ;
1134- Assert . Throws < ArgumentNullException > ( ( ) => list . FindLast ( null ) ) ;
1132+ Assert . Throws < ArgumentNullException > ( ( ) => list . FindLast ( null ! ) ) ;
11351133
11361134 Assert . Equal ( 0 , list . FindLast ( i => i < 0 ) ) ;
11371135 Assert . Equal ( 0 , reference . FindLast ( i => i < 0 ) ) ;
@@ -1166,7 +1164,7 @@ public void TestTrueForAll()
11661164 {
11671165 var list = ImmutableTreeList . CreateBuilder < int > ( ) ;
11681166 Assert . True ( list . TrueForAll ( i => false ) ) ;
1169- Assert . Throws < ArgumentNullException > ( ( ) => list . TrueForAll ( null ) ) ;
1167+ Assert . Throws < ArgumentNullException > ( ( ) => list . TrueForAll ( null ! ) ) ;
11701168
11711169 list . Add ( 1 ) ;
11721170 Assert . True ( list . TrueForAll ( i => i > 0 ) ) ;
0 commit comments