dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/tests/runtime/System TestArray.cs,1.


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/tests/runtime/System TestArray.cs,1.2,1.3
Date: Mon, 14 Apr 2003 07:14:33 -0400

Update of /cvsroot/dotgnu-pnet/pnetlib/tests/runtime/System
In directory subversions:/tmp/cvs-serv7325/tests/runtime/System

Modified Files:
        TestArray.cs 
Log Message:


Test cases for "Array.Clear".


Index: TestArray.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/tests/runtime/System/TestArray.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** TestArray.cs        14 Apr 2003 05:23:33 -0000      1.2
--- TestArray.cs        14 Apr 2003 11:14:31 -0000      1.3
***************
*** 161,164 ****
--- 161,243 ----
                        }
  
+       // Test clearing the elements of an array.
+       public void TestArrayClear()
+                       {
+                               // Test parameter checks.
+                               try
+                               {
+                                       Array.Clear(null, 0, 0);
+                                       Fail("Clear (1)");
+                               }
+                               catch(ArgumentNullException)
+                               {
+                                       // Test succeeded.
+                               }
+                               Array.Clear(new int [3, 3], 0, 9);      // 
Indices are relative.
+                               int[] array = new int [] {1, 2, 3, 5, 6};
+                               try
+                               {
+                                       Array.Clear(array, -1, 1);
+                                       Fail("Clear (2)");
+                               }
+                               catch(ArgumentOutOfRangeException)
+                               {
+                                       // Test succeeded.
+                               }
+                               try
+                               {
+                                       Array.Clear(array, 0, -1);
+                                       Fail("Clear (3)");
+                               }
+                               catch(ArgumentOutOfRangeException)
+                               {
+                                       // Test succeeded.
+                               }
+                               try
+                               {
+                                       Array.Clear(array, 6, 0);
+                                       Fail("Clear (4)");
+                               }
+                               catch(ArgumentException)
+                               {
+                                       // Test succeeded.
+                               }
+                               try
+                               {
+                                       Array.Clear(array, 5, 1);
+                                       Fail("Clear (5)");
+                               }
+                               catch(ArgumentException)
+                               {
+                                       // Test succeeded.
+                               }
+                               try
+                               {
+                                       Array.Clear(array, 4, 5);
+                                       Fail("Clear (6)");
+                               }
+                               catch(ArgumentException)
+                               {
+                                       // Test succeeded.
+                               }
+ 
+                               // "array" should still have its original 
values.
+                               AssertEquals("Clear (7a)", 1, array[0]);
+                               AssertEquals("Clear (7b)", 2, array[1]);
+                               AssertEquals("Clear (7c)", 3, array[2]);
+                               AssertEquals("Clear (7d)", 5, array[3]);
+                               AssertEquals("Clear (7e)", 6, array[4]);
+ 
+                               // Clear a subset of the array.
+                               Array.Clear(array, 2, 2);
+ 
+                               // Check that the clear was successful.
+                               AssertEquals("Clear (8a)", 1, array[0]);
+                               AssertEquals("Clear (8b)", 2, array[1]);
+                               AssertEquals("Clear (8c)", 0, array[2]);
+                               AssertEquals("Clear (8d)", 0, array[3]);
+                               AssertEquals("Clear (8e)", 6, array[4]);
+                       }
+ 
        // Test sorting an array.
        public void TestArraySort()





reply via email to

[Prev in Thread] Current Thread [Next in Thread]