Author: duncan
Date: 2006-08-05 10:44:26 -0400 (Sat, 05 Aug 2006)
New Revision: 63387

Modified:
   trunk/mcs/class/corlib/System/ChangeLog
   trunk/mcs/class/corlib/System/Char.cs
   trunk/mcs/class/corlib/Test/System/ChangeLog
   trunk/mcs/class/corlib/Test/System/CharTest.cs
Log:

2006-08-05  Duncan Mak  <[EMAIL PROTECTED]>

        * Char.cs (TryParse): Implemented missing 2.0 method.

        * CharTest.cs (TestTryParseValid, TestTryParseInvalid): Added
        tests for 2.0 method Char.TryParse.


Modified: trunk/mcs/class/corlib/System/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/System/ChangeLog     2006-08-05 01:51:56 UTC (rev 
63386)
+++ trunk/mcs/class/corlib/System/ChangeLog     2006-08-05 14:44:26 UTC (rev 
63387)
@@ -1,3 +1,7 @@
+2006-08-05  Duncan Mak  <[EMAIL PROTECTED]>
+
+       * Char.cs (TryParse): Implemented missing 2.0 method.
+
 2006-07-28  Jonathan Chambers  <[EMAIL PROTECTED]>
 
        * __ComObject.cs: Added support for marshalling objects.

Modified: trunk/mcs/class/corlib/System/Char.cs
===================================================================
--- trunk/mcs/class/corlib/System/Char.cs       2006-08-05 01:51:56 UTC (rev 
63386)
+++ trunk/mcs/class/corlib/System/Char.cs       2006-08-05 14:44:26 UTC (rev 
63387)
@@ -570,6 +570,19 @@
                        return IsWhiteSpace (str[index]);
                }
 
+#if NET_2_0
+               public static bool TryParse (string s, out char result)
+               {
+                       if (s == null || s.Length != 1) {
+                               result = (char) 0;
+                               return false;
+                       }
+
+                       result = s [0];
+                       return true;
+               }
+#endif
+
                public static char Parse (string str)
                {
                        if (str == null) 

Modified: trunk/mcs/class/corlib/Test/System/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/Test/System/ChangeLog        2006-08-05 01:51:56 UTC 
(rev 63386)
+++ trunk/mcs/class/corlib/Test/System/ChangeLog        2006-08-05 14:44:26 UTC 
(rev 63387)
@@ -1,3 +1,8 @@
+2006-08-05  Duncan Mak  <[EMAIL PROTECTED]>
+
+       * CharTest.cs (TestTryParseValid, TestTryParseInvalid): Added
+       tests for 2.0 method Char.TryParse.
+
 2006-07-24  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * CharTest.cs : added tests for utf32 conversion methods.

Modified: trunk/mcs/class/corlib/Test/System/CharTest.cs
===================================================================
--- trunk/mcs/class/corlib/Test/System/CharTest.cs      2006-08-05 01:51:56 UTC 
(rev 63386)
+++ trunk/mcs/class/corlib/Test/System/CharTest.cs      2006-08-05 14:44:26 UTC 
(rev 63387)
@@ -463,6 +463,26 @@
                Assert(c1.Equals(Char.Parse(s1)));
        }       
 
+#if NET_2_0
+       public void TestTryParseValid ()
+       {
+               char c1 = 'a';
+               string s1 = "a";
+               char c2;
+
+               AssertEquals ("TryParse1", true, Char.TryParse (s1, out c2));
+               AssertEquals ("TryParse2", c2, c1);
+       }
+
+       public void TestTryParseInvalid ()
+       {
+               string s = "abc";
+               char c;
+               AssertEquals ("TryParse3", false, Char.TryParse (s, out c));
+               AssertEquals ("TryParse4", '\0', c);
+       }
+#endif
+       
        public void TestToLower()
        {
                char a1 = 'a';

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to