@@ -26,6 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2626
2727using NUnit . Framework ;
2828using System ;
29+ using System . Buffers ;
2930using System . Collections ;
3031using System . Collections . Generic ;
3132using System . Linq ;
@@ -127,17 +128,11 @@ public static void SetGetTest(ILargeArray<long> largeArray, long offset)
127128 return ;
128129 }
129130
130- // create array with ascending order
131+ // create and verify array with ascending order
131132 for ( long i = 0 ; i < capacity ; i ++ )
132133 {
133134 largeArray [ i ] = i ;
134- }
135-
136- // verify ascending order
137- for ( long i = 0 ; i < capacity ; i ++ )
138- {
139- long expectedValue = i ;
140- Assert . AreEqual ( expectedValue , largeArray [ i ] ) ;
135+ Assert . AreEqual ( i , largeArray [ i ] ) ;
141136 }
142137
143138 long dummy = 0L ;
@@ -179,17 +174,11 @@ public static void EnumerationTest(ILargeArray<long> largeArray, long offset)
179174 return ;
180175 }
181176
182- // create array with ascending order
177+ // create and verify array with ascending order
183178 for ( long i = 0 ; i < capacity ; i ++ )
184179 {
185180 largeArray [ i ] = i ;
186- }
187-
188- // verify ascending order
189- for ( long i = 0 ; i < capacity ; i ++ )
190- {
191- long expectedValue = i ;
192- Assert . AreEqual ( expectedValue , largeArray [ i ] ) ;
181+ Assert . AreEqual ( i , largeArray [ i ] ) ;
193182 }
194183
195184 // GetAll
@@ -295,14 +284,9 @@ public static void SortTest(ILargeArray<long> largeArray, long offset)
295284
296285 // create array with descending order
297286 for ( long i = 0 ; i < capacity ; i ++ )
298- {
299- largeArray [ i ] = capacity - 1L - i ;
300- }
301-
302- // verify descending order
303- for ( long i = 0 ; i < capacity ; i ++ )
304287 {
305288 long expectedValue = capacity - 1L - i ;
289+ largeArray [ i ] = expectedValue ;
306290 Assert . AreEqual ( expectedValue , largeArray [ i ] ) ;
307291 }
308292
@@ -361,17 +345,11 @@ public static void BinarySearchTest(ILargeArray<long> largeArray, long offset)
361345 return ;
362346 }
363347
364- // create array with ascending order
348+ // create and verify array with ascending order
365349 for ( long i = 0 ; i < capacity ; i ++ )
366350 {
367351 largeArray [ i ] = i ;
368- }
369-
370- // verify ascending order
371- for ( long i = 0 ; i < capacity ; i ++ )
372- {
373- long expectedValue = i ;
374- Assert . AreEqual ( expectedValue , largeArray [ i ] ) ;
352+ Assert . AreEqual ( i , largeArray [ i ] ) ;
375353 }
376354
377355 // Binary Search
@@ -443,17 +421,11 @@ public static void ContainsTest(ILargeArray<long> largeArray, long offset)
443421 return ;
444422 }
445423
446- // create array with ascending order
424+ // create and verify array with ascending order
447425 for ( long i = 0 ; i < capacity ; i ++ )
448426 {
449427 largeArray [ i ] = i ;
450- }
451-
452- // Verify ascending order
453- for ( long i = 0 ; i < capacity ; i ++ )
454- {
455- long expectedValue = i ;
456- Assert . AreEqual ( expectedValue , largeArray [ i ] ) ;
428+ Assert . AreEqual ( i , largeArray [ i ] ) ;
457429 }
458430
459431 // Contains
@@ -476,5 +448,35 @@ public static void ContainsTest(ILargeArray<long> largeArray, long offset)
476448 // capacity must not be contained
477449 Assert . AreEqual ( false , largeArray . Contains ( capacity ) ) ;
478450 }
451+
452+ public static void CopyTest ( ILargeArray < long > largeArray , long offset )
453+ {
454+ long capacity = largeArray . Count ;
455+ long count = capacity - 2L * offset ;
456+
457+ // offset must not be less than 0
458+ Assert . Throws < ArgumentException > ( ( ) => largeArray . Contains ( 0L , - 1L , count ) ) ;
459+
460+ // count must not be less than 0
461+ Assert . Throws < ArgumentException > ( ( ) => largeArray . Contains ( 0L , 0L , - 1L ) ) ;
462+
463+ // range must not exceed
464+ Assert . Throws < ArgumentException > ( ( ) => largeArray . Contains ( 0L , 1L , capacity ) ) ;
465+
466+ if ( count < 0L || offset + count > capacity )
467+ {
468+ return ;
469+ }
470+
471+ // create and verify array with ascending order
472+ for ( long i = 0 ; i < capacity ; i ++ )
473+ {
474+ largeArray [ i ] = i ;
475+ Assert . AreEqual ( i , largeArray [ i ] ) ;
476+ }
477+
478+ LargeArray < long > targetArray = new LargeArray < long > ( capacity , 0L ) ;
479+ largeArray . CopyTo ( targetArray , capacity ) ;
480+ }
479481 }
480482}
0 commit comments