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 TestString.cs,1.


From: Jonathan Springer <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/tests/runtime/System TestString.cs,1.1,1.2
Date: Mon, 11 Nov 2002 17:37:45 -0500

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

Modified Files:
        TestString.cs 
Log Message:


String clean-up: execeptions and LastIndexOf*


Index: TestString.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/tests/runtime/System/TestString.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** TestString.cs       2 Oct 2002 08:47:35 -0000       1.1
--- TestString.cs       11 Nov 2002 22:37:43 -0000      1.2
***************
*** 242,248 ****
                {
                        bool q=bad.Equals("nothing");
!                       Fail("bad.Equals(\"nothing\") should have thrown a 
ArgumentNullException");
                }
!               catch(ArgumentNullException err)
                {
                        //great !
--- 242,248 ----
                {
                        bool q=bad.Equals("nothing");
!                       Fail("bad.Equals(\"nothing\") should have thrown a 
NullReferenceException");
                }
!               catch(NullReferenceException err)
                {
                        //great !
***************
*** 262,272 ****
        {
        /*TODO*/
!               AssertEquals ("String.Format(\"\",0)", String.Format ("", 
0),"");
                
                AssertEquals ("String.Format(\"{0}\",\"FooBar\")", 
!               String.Format ("{0}","FooBar"),"FooBar");
  
                AssertEquals ("String.Format(\"{0}\",111)", 
!               String.Format ("{0}",111),"111");
  
                try
--- 262,272 ----
        {
        /*TODO*/
!               AssertEquals ("String.Format(\"\",0)", "", String.Format ("", 
0));
                
                AssertEquals ("String.Format(\"{0}\",\"FooBar\")", 
!                               "FooBar", String.Format ("{0}","FooBar"));
  
                AssertEquals ("String.Format(\"{0}\",111)", 
!                               "111", String.Format ("{0}",111));
  
                try
***************
*** 274,277 ****
--- 274,285 ----
                        String.Format(null,12);
                        Fail("String.Format(null,12) should throw an 
ArgumentNullException");
+               }
+               catch(ArgumentNullException err)
+               {
+                       // all's well 
+               }
+ 
+               try
+               {
                        String.Format("Er..",null);
                        Fail("String.Format(\"Er...\",null) should throw an 
ArgumentNullException");
***************
*** 286,291 ****
--- 294,315 ----
                        String.Format("{-1}",12);
                        Fail("String.Format(\"{-1}\",12) should throw an 
FormatException");
+               }
+               catch(FormatException err)
+               {
+                       // all's well 
+               }
+ 
+               try
+               {
                        String.Format("{3}",12);
                        Fail("String.Format(\"{3}\",12) should throw an 
FormatException");
+               }
+               catch(FormatException err)
+               {
+                       // all's well 
+               }
+ 
+               try
+               {
                        String.Format("{}",12);
                        Fail("String.Format(\"{}\",12) should throw an 
FormatException");
***************
*** 295,323 ****
                        // all's well 
                }
                AssertEquals("String.Format (\"<{0,5}>\", 12)",
!                       String.Format ("<{0,5}>", 12),"<   12>");
                
                AssertEquals("String.Format (\"<{0,5}>\", 12)",
!                       String.Format ("<{0,-5}>", 12),"<12   >");
  
                AssertEquals ("String.Format(\"The {0} of 
{1}\",\"Church\",\"Emacs\")",
!                       String.Format ("The {0} of {1}","Church", "Emacs"),
!                       "The Church of Emacs");
                
!               AssertEquals("String.Format(\"G{0} N{1} 
U{2}\",\"nu's\",\"ot\",\"nix\")"
!                       ,String.Format ("G{0} N{1} U{2}","nu's", "ot", "nix"),
!                       "Gnu's Not Unix");
  
                AssertEquals ("String.Format (\"{0:x8}\", 
0xcafebabe),\"cafebabe\")",
!                       String.Format ("{0:x8}", 0xcafebabe),"cafebabe");
  
                AssertEquals ("String.Format (\"<{0,5:x3}>\", 0x55)",
!                       String.Format ("<{0,5:x3}>", 0x55),"<  055>");
        
                AssertEquals ("String.Format (\"<{0,-5:x3}>\", 0x55)",
!                       String.Format ("<{0,-5:x3}>", 0x55),"<055  >");
                        
                AssertEquals ("String.Format (\"if({0}==0){{ .... }}\",\"i\")",
!               String.Format ("if({0}==0){{ .... }}","i"),"if(i==0){ .... }");
        }
  
--- 319,351 ----
                        // all's well 
                }
+ 
                AssertEquals("String.Format (\"<{0,5}>\", 12)",
!                       "<   12>",String.Format ("<{0,5}>", 12));
                
                AssertEquals("String.Format (\"<{0,5}>\", 12)",
!                       "<12   >",String.Format ("<{0,-5}>", 12));
  
                AssertEquals ("String.Format(\"The {0} of 
{1}\",\"Church\",\"Emacs\")",
!                       "The Church of Emacs",
!                       String.Format ("The {0} of {1}", "Church", "Emacs"));
                
!               AssertEquals("String.Format(\"G{0} N{1} 
U{2}\",\"nu's\",\"ot\",\"nix\")",
!                       "Gnu's Not Unix", 
!                       String.Format ("G{0} N{1} U{2}", "nu's", "ot", "nix"));
  
                AssertEquals ("String.Format (\"{0:x8}\", 
0xcafebabe),\"cafebabe\")",
!                       "cafebabe", String.Format ("{0:x8}", 0xcafebabe));
! 
!               AssertEquals ("String.Format (\"{0:x8}\", 
0xcafebabe),\"cafebabe\")",
!                       "CAFEBABE", String.Format ("{0:X8}", 0xcafebabe));
  
                AssertEquals ("String.Format (\"<{0,5:x3}>\", 0x55)",
!                       "<  055>", String.Format ("<{0,5:x3}>", 0x55));
        
                AssertEquals ("String.Format (\"<{0,-5:x3}>\", 0x55)",
!                       "<055  >", String.Format ("<{0,-5:x3}>", 0x55));
                        
                AssertEquals ("String.Format (\"if({0}==0){{ .... }}\",\"i\")",
!                       "if(i==0){ .... }", String.Format ("if({0}==0){{ .... 
}}", "i"));
        }
  
***************
*** 599,602 ****
--- 627,631 ----
                catch (ArgumentOutOfRangeException)
                {
+                       // This looks like brain damage in the spec, but it's 
easy enough to implement.
                        Fail("foo.LastIndexOf('f',foo.Length) should NOT throw 
an ArgumentOutOfRangeException");
                }
***************
*** 679,687 ****
                try
                {
!                       
AssertEquals("foo.LastIndexOf('r',foo.Length+10,11)",28,foo.LastIndexOf('r',foo.Length+10,11));
 // isn't it?
                }
                catch (ArgumentOutOfRangeException)
                {
!                       Fail("foo.LastIndexOf('r',foo.Length+10,11) should NOT 
throw an ArgumentOutOfRangeException");
                }       
                try
--- 708,716 ----
                try
                {
!                       
AssertEquals("foo.LastIndexOf('r',foo.Length+10,12)",28,foo.LastIndexOf('r',foo.Length+10,12));
 // isn't it?
                }
                catch (ArgumentOutOfRangeException)
                {
!                       Fail("foo.LastIndexOf('r',foo.Length+10,12) should NOT 
throw an ArgumentOutOfRangeException");
                }       
                try
***************
*** 734,738 ****
                /* String.LastIndexOf(String,int) */
                
AssertEquals("foo.LastIndexOf(\"Bar\",foo.Length-1)",26,foo.LastIndexOf("Bar",foo.Length-1));
!               
AssertEquals("foo.LastIndexOf(\"Bar\",foo.Length-2)",-1,foo.LastIndexOf("Bar",foo.Length-2));
                
AssertEquals("foo.LastIndexOf(\"Fu\",foo.Length-3)",23,foo.LastIndexOf("Fu",foo.Length-3));
                
AssertEquals("foo.LastIndexOf(\"Fu\",foo.Length-6)",-1,foo.LastIndexOf("Fu",foo.Length-6));
--- 763,767 ----
                /* String.LastIndexOf(String,int) */
                
AssertEquals("foo.LastIndexOf(\"Bar\",foo.Length-1)",26,foo.LastIndexOf("Bar",foo.Length-1));
!               
AssertEquals("foo.LastIndexOf(\"Bar\",foo.Length-2)",4,foo.LastIndexOf("Bar",foo.Length-2));
                
AssertEquals("foo.LastIndexOf(\"Fu\",foo.Length-3)",23,foo.LastIndexOf("Fu",foo.Length-3));
                
AssertEquals("foo.LastIndexOf(\"Fu\",foo.Length-6)",-1,foo.LastIndexOf("Fu",foo.Length-6));
***************
*** 792,804 ****
                /* String.LastIndexOf(String,int,int) */
                
AssertEquals("foo.LastIndexOf(\"Bar\",foo.Length-1,foo.Length)",26,foo.LastIndexOf("Bar",foo.Length-1,foo.Length));
!               
AssertEquals("foo.LastIndexOf(\"Bar\",foo.Length-2,foo.Length-1)",-1,foo.LastIndexOf("Bar",foo.Length-2,foo.Length-1));
                
AssertEquals("foo.LastIndexOf(\"Bar\",foo.Length-1,3)",26,foo.LastIndexOf("Bar",foo.Length-1,3));
                
AssertEquals("foo.LastIndexOf(\"Bar\",foo.Length-2,3)",-1,foo.LastIndexOf("Bar",foo.Length-2,3));
                
AssertEquals("foo.LastIndexOf(\"Bar\",foo.Length-1,2)",-1,foo.LastIndexOf("Bar",foo.Length-1,2));
!               
AssertEquals("foo.LastIndexOf(\"Fu\",foo.Length-3,foo.Length-2)",23,foo.LastIndexOf("Fu",foo.Length-3,foo.Length-2));
!               
AssertEquals("foo.LastIndexOf(\"Fu\",foo.Length-4,foo.Length-3)",-1,foo.LastIndexOf("Fu",foo.Length-4,foo.Length-3));
!               
AssertEquals("foo.LastIndexOf(\"Fu\",foo.Length-3,3)",23,foo.LastIndexOf("Fu",foo.Length-3,3));
!               
AssertEquals("foo.LastIndexOf(\"Fu\",foo.Length-4,3)",-1,foo.LastIndexOf("Fu",foo.Length-4,3));
                
AssertEquals("foo.LastIndexOf(\"Fu\",foo.Length-6,foo.Length-5)",-1,foo.LastIndexOf("Fu",foo.Length-6,foo.Length-5));
                try
                {
--- 821,832 ----
                /* String.LastIndexOf(String,int,int) */
                
AssertEquals("foo.LastIndexOf(\"Bar\",foo.Length-1,foo.Length)",26,foo.LastIndexOf("Bar",foo.Length-1,foo.Length));
!               
AssertEquals("foo.LastIndexOf(\"Bar\",foo.Length-2,foo.Length-1)",4,foo.LastIndexOf("Bar",foo.Length-2,foo.Length-1));
                
AssertEquals("foo.LastIndexOf(\"Bar\",foo.Length-1,3)",26,foo.LastIndexOf("Bar",foo.Length-1,3));
                
AssertEquals("foo.LastIndexOf(\"Bar\",foo.Length-2,3)",-1,foo.LastIndexOf("Bar",foo.Length-2,3));
                
AssertEquals("foo.LastIndexOf(\"Bar\",foo.Length-1,2)",-1,foo.LastIndexOf("Bar",foo.Length-1,2));
!               
AssertEquals("foo.LastIndexOf(\"Fu\",foo.Length-4,foo.Length-3)",23,foo.LastIndexOf("Fu",foo.Length-4,foo.Length-3));
                
AssertEquals("foo.LastIndexOf(\"Fu\",foo.Length-6,foo.Length-5)",-1,foo.LastIndexOf("Fu",foo.Length-6,foo.Length-5));
+               
AssertEquals("foo.LastIndexOf(\"Fu\",foo.Length-4,3)",23,foo.LastIndexOf("Fu",foo.Length-4,3));
+               
AssertEquals("foo.LastIndexOf(\"Fu\",foo.Length-6,3)",-1,foo.LastIndexOf("Fu",foo.Length-6,3));
                try
                {
***************
*** 873,876 ****
--- 901,906 ----
        public void TestStringLastIndexOfAny()
        {
+               //            00000000001111111111222222222
+               //            01234567890123456789012345678
                String foo = "Foo Bar foo bar fu bar Fu Bar";
  
***************
*** 946,952 ****
                AssertEquals("foo.LastIndexOfAny(new char[] 
{'r','a','B'},foo.Length-1,1)",28,foo.LastIndexOfAny(new char[] 
{'r','a','B'},foo.Length-1,1));
                AssertEquals("foo.LastIndexOfAny(new char[] 
{'r','a','B'},foo.Length-2,2)",27,foo.LastIndexOfAny(new char[] 
{'r','a','B'},foo.Length-2,2));
!               AssertEquals("foo.LastIndexOfAny(new char[] 
{'B'},foo.Length-1,foo.Length)",28,foo.LastIndexOfAny(new char[] 
{'B'},foo.Length-1,foo.Length));
!               AssertEquals("foo.LastIndexOfAny(new char[] 
{'F'},foo.Length,foo.Length)",23,foo.LastIndexOfAny(new char[] 
{'F'},foo.Length,foo.Length));
!               AssertEquals("foo.LastIndexOfAny(new char[] 
{'F'},foo.Length-10,foo.Length-11)",0,foo.LastIndexOfAny(new char[] 
{'F'},foo.Length-10,foo.Length-11));
                AssertEquals("foo.LastIndexOfAny(new char[] 
{'F'},foo.Length-10,foo.Length-10)",-1,foo.LastIndexOfAny(new char[] 
{'F'},foo.Length-10,foo.Length-10));
                AssertEquals("foo.LastIndexOfAny(new char[] 
{'F'},foo.Length+10,foo.Length)",23,foo.LastIndexOfAny(new char[] 
{'F'},foo.Length+10,foo.Length));
--- 976,990 ----
                AssertEquals("foo.LastIndexOfAny(new char[] 
{'r','a','B'},foo.Length-1,1)",28,foo.LastIndexOfAny(new char[] 
{'r','a','B'},foo.Length-1,1));
                AssertEquals("foo.LastIndexOfAny(new char[] 
{'r','a','B'},foo.Length-2,2)",27,foo.LastIndexOfAny(new char[] 
{'r','a','B'},foo.Length-2,2));
!               AssertEquals("foo.LastIndexOfAny(new char[] 
{'B'},foo.Length-1,foo.Length)",26,foo.LastIndexOfAny(new char[] 
{'B'},foo.Length-1,foo.Length));
!               try
!               {
!                       AssertEquals("foo.LastIndexOfAny(new char[] 
{'F'},foo.Length,foo.Length)",23, foo.LastIndexOfAny(new char[] 
{'F'},foo.Length,foo.Length));
!               }
!               catch (ArgumentOutOfRangeException)
!               {
!                       Fail("foo.LastIndexOfAny(new char[] 
{'F'},foo.Length,foo.Length) should NOT throw an ArgumentOutOfRangeException");
!                       // flashing some leather
!               }
!               AssertEquals("foo.LastIndexOfAny(new char[] 
{'F'},foo.Length-11,foo.Length-10)",0,foo.LastIndexOfAny(new char[] 
{'F'},foo.Length-11,foo.Length-10));
                AssertEquals("foo.LastIndexOfAny(new char[] 
{'F'},foo.Length-10,foo.Length-10)",-1,foo.LastIndexOfAny(new char[] 
{'F'},foo.Length-10,foo.Length-10));
                AssertEquals("foo.LastIndexOfAny(new char[] 
{'F'},foo.Length+10,foo.Length)",23,foo.LastIndexOfAny(new char[] 
{'F'},foo.Length+10,foo.Length));





reply via email to

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