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 TestArgIterator


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/tests/runtime/System TestArgIterator.cs,1.1,1.2
Date: Sun, 13 Apr 2003 21:17:52 -0400

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

Modified Files:
        TestArgIterator.cs 
Log Message:


Test cases for static vararg methods.


Index: TestArgIterator.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/tests/runtime/System/TestArgIterator.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** TestArgIterator.cs  14 Apr 2003 00:46:10 -0000      1.1
--- TestArgIterator.cs  14 Apr 2003 01:17:50 -0000      1.2
***************
*** 176,179 ****
--- 176,265 ----
                        }
  
+       // Helper method for "TestArgIteratorGetValueStatic".
+       private static void TestValuesStatic
+                               (String testNum, Object[] values, __arglist)
+                       {
+                               Object expected, actual;
+                               ArgIterator iter = new ArgIterator(__arglist);
+                               int count = iter.GetRemainingCount();
+                               AssertEquals("Length " + testNum, 
values.Length, count);
+                               while(count > 0)
+                               {
+                                       expected = values[values.Length - 
count];
+                                       actual = 
TypedReference.ToObject(iter.GetNextArg());
+                                       if(expected == null)
+                                       {
+                                               AssertNull("ValueCheck " + 
testNum, actual);
+                                       }
+                                       else
+                                       {
+                                               Assert("ValueCheck " + testNum,
+                                                          
expected.Equals(actual));
+                                       }
+                                       --count;
+                                       AssertEquals("Remaining " + testNum,
+                                                                count, 
iter.GetRemainingCount());
+                               }
+                               try
+                               {
+                                       iter.GetNextArg();
+                                       Fail("EndCheck " + testNum);
+                               }
+                               catch(InvalidOperationException)
+                               {
+                                       // We expect this exception at the end 
of the list.
+                               }
+                               AssertEquals("Remaining " + testNum, 0,
+                                                        
iter.GetRemainingCount());
+ 
+                               // Restart and run the test again to make sure 
that
+                               // the first iteration did not modify the 
vararg values.
+                               iter = new ArgIterator(__arglist);
+                               count = iter.GetRemainingCount();
+                               AssertEquals("Length " + testNum, 
values.Length, count);
+                               while(count > 0)
+                               {
+                                       expected = values[values.Length - 
count];
+                                       actual = 
TypedReference.ToObject(iter.GetNextArg());
+                                       if(expected == null)
+                                       {
+                                               AssertNull("ValueCheck " + 
testNum, actual);
+                                       }
+                                       else
+                                       {
+                                               Assert("ValueCheck " + testNum,
+                                                          
expected.Equals(actual));
+                                       }
+                                       --count;
+                                       AssertEquals("Remaining " + testNum,
+                                                                count, 
iter.GetRemainingCount());
+                               }
+                               try
+                               {
+                                       iter.GetNextArg();
+                                       Fail("EndCheck " + testNum);
+                               }
+                               catch(InvalidOperationException)
+                               {
+                                       // We expect this exception at the end 
of the list.
+                               }
+                               AssertEquals("Remaining " + testNum, 0,
+                                                        
iter.GetRemainingCount());
+                       }
+ 
+       // Test getting the values of the arguments to a vararg method.
+       public void TestArgIteratorGetValueStatic()
+                       {
+                               TestValuesStatic("(0)", new Object [0], 
__arglist());
+                               TestValuesStatic("(1)", new Object [] {1}, 
__arglist(1));
+                               TestValuesStatic("(2)", new Object [] {1, 
"hello"},
+                                                 __arglist(1, "hello"));
+                               TestValuesStatic("(3)", new Object [] {1, 
"hello", null},
+                                                 __arglist(1, "hello", null));
+                               TestValuesStatic("(4)", new Object []
+                                                               {1, "hello", 
null, TypeCode.DBNull},
+                                                 __arglist(1, "hello", null, 
TypeCode.DBNull));
+                       }
+ 
        // Helper method for "TestArgIteratorGetValueByType".
        private void TestByType(String testNum, Type[] types, __arglist)
***************
*** 266,270 ****
        // Check that we cannot do anything with an uninitialized ArgIterator.
        private ArgIterator emptyIterator;
!       public void TestArgIteratorUninit()
                        {
                                AssertEquals("Remaining", 0,
--- 352,356 ----
        // Check that we cannot do anything with an uninitialized ArgIterator.
        private ArgIterator emptyIterator;
!       public void TestArgIteratorUninitialized()
                        {
                                AssertEquals("Remaining", 0,





reply via email to

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