2010-04-15 Jb Evain <jbevain@novell.com>
authorJb Evain <jbevain@gmail.com>
Thu, 15 Apr 2010 19:26:09 +0000 (19:26 -0000)
committerJb Evain <jbevain@gmail.com>
Thu, 15 Apr 2010 19:26:09 +0000 (19:26 -0000)
* GuidTest.cs: add tests for net_4_0 ParseExact methods.

svn path=/trunk/mcs/; revision=155537

mcs/class/corlib/Test/System/ChangeLog
mcs/class/corlib/Test/System/GuidTest.cs

index a51f837aea81a4908c12f308fdcdd390352a3faa..06867e0214d68f2fa59fe0b88abffb53f36b2636 100644 (file)
@@ -1,3 +1,7 @@
+2010-04-15  Jb Evain  <jbevain@novell.com>
+
+       * GuidTest.cs: add tests for net_4_0 ParseExact methods.
+
 2010-04-13  Zoltan Varga  <vargaz@gmail.com>
 
        * ConvertTest.cs: Add a test for #596339.
index 51c1a225c2476c09a10fd0e8c50d8eb6c43cbfbc..245ed727877a5b5c3d48ca645848c9a5f8f74fe3 100644 (file)
@@ -289,5 +289,53 @@ namespace MonoTests.System {
                {
                        new Guid (0x00010203, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f).ToString ("This is invalid");
                }
+
+#if NET_4_0
+
+               /*
+                       N = new Guid ("000102030405060708090a0b0c0d0e0f"); 
+                       D = new Guid ("00010203-0405-0607-0809-0a0b0c0d0e0f"); 
+                       B = new Guid ("{00010203-0405-0607-0809-0A0B0C0D0E0F}"); 
+                       P = new Guid ("(00010203-0405-0607-0809-0A0B0C0D0E0F)");
+                       X = new Guid ("{0x00010203,0x0405,0x0607,{0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f}}");
+
+                       string expected = "00010203-0405-0607-0809-0a0b0c0d0e0f";
+               */
+
+               [Test]
+               public void ParseExact ()
+               {
+                       const string expected = "00010203-0405-0607-0809-0a0b0c0d0e0f";
+
+                       var guid = Guid.ParseExact ("000102030405060708090a0b0c0d0e0f", "N");
+                       Assert.AreEqual (expected, guid.ToString ());
+
+                       guid = Guid.ParseExact ("00010203-0405-0607-0809-0a0b0c0d0e0f", "D");
+                       Assert.AreEqual (expected, guid.ToString ());
+
+                       guid = Guid.ParseExact ("{00010203-0405-0607-0809-0A0B0C0D0E0F}", "B");
+                       Assert.AreEqual (expected, guid.ToString ());
+
+                       guid = Guid.ParseExact ("(00010203-0405-0607-0809-0A0B0C0D0E0F)", "P");
+                       Assert.AreEqual (expected, guid.ToString ());
+
+                       guid = Guid.ParseExact ("{0x00010203,0x0405,0x0607,{0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f}}", "X");
+                       Assert.AreEqual (expected, guid.ToString ());
+               }
+
+               [Test]
+               [ExpectedException (typeof (FormatException))]
+               public void ParseExactN ()
+               {
+                       Guid.ParseExact ("00010203-0405-0607-0809-0a0b0c0d0e0f", "N");
+               }
+
+               [Test]
+               [ExpectedException (typeof (FormatException))]
+               public void ParseExactD ()
+               {
+                       Guid.ParseExact ("{0x00010203,0x0405,0x0607,{0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f}}", "D");
+               }
+#endif
        }
 }