Author: spouliot
Date: 2005-12-05 13:44:39 -0500 (Mon, 05 Dec 2005)
New Revision: 53940

Modified:
   trunk/mcs/class/corlib/Test/System.Collections/ChangeLog
   trunk/mcs/class/corlib/Test/System.Collections/ComparerTest.cs
Log:
2005-12-05  Sebastien Pouliot  <[EMAIL PROTECTED]>

        * ComparerTest.cs: Removed "NotWorking" from "Invariant" test case 
        (it's now working). Added new test cases for ISerializable (added in
        SP1 and present in 2.0) and completed coverage with tests for ctor.



Modified: trunk/mcs/class/corlib/Test/System.Collections/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/Test/System.Collections/ChangeLog    2005-12-05 
18:44:17 UTC (rev 53939)
+++ trunk/mcs/class/corlib/Test/System.Collections/ChangeLog    2005-12-05 
18:44:39 UTC (rev 53940)
@@ -1,3 +1,9 @@
+2005-12-05  Sebastien Pouliot  <[EMAIL PROTECTED]>
+
+       * ComparerTest.cs: Removed "NotWorking" from "Invariant" test case 
+       (it's now working). Added new test cases for ISerializable (added in
+       SP1 and present in 2.0) and completed coverage with tests for ctor.
+
 2005-09-01  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * HashtableTest.cs : testcase for #75790.

Modified: trunk/mcs/class/corlib/Test/System.Collections/ComparerTest.cs
===================================================================
--- trunk/mcs/class/corlib/Test/System.Collections/ComparerTest.cs      
2005-12-05 18:44:17 UTC (rev 53939)
+++ trunk/mcs/class/corlib/Test/System.Collections/ComparerTest.cs      
2005-12-05 18:44:39 UTC (rev 53940)
@@ -3,12 +3,12 @@
 using System;
 using System.Collections;
 using System.Globalization;
+using System.Runtime.Serialization;
+
 using NUnit.Framework;
 
-
 namespace MonoTests.System.Collections {
 
-
        [TestFixture]
        public class ComparerTest {
 
@@ -24,39 +24,36 @@
                public void TestCompare ()
                {
                        Comparer c = Comparer.Default;
-
-                       bool thrown = false;
-
-                       try {
-                               c.Compare (new Object (), new Object ());
-                       } catch (ArgumentException) {
-                               thrown = true;
-                       }
-
-                       Assert.IsTrue (thrown, "ArgumentException expected");
-
                        Assert.IsTrue (c.Compare (1, 2) < 0, "1,2");
                        Assert.IsTrue (c.Compare (2, 2) == 0, "2,2");
                        Assert.IsTrue (c.Compare (3, 2) > 0, "3,2");
+               }
 
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void Compare_FirstIComparer ()
+               {
+                       Assert.IsTrue (Comparer.Default.Compare (1, new object 
()) > 0, "int,object");
                }
 
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void Compare_SecondIComparer ()
+               {
+                       Assert.IsTrue (Comparer.Default.Compare (new object (), 
1) > 0, "object,int");
+               }
 
                [Test]
-               [Category("NotWorking")]
+               [ExpectedException (typeof (ArgumentException))]
+               public void Compare_BothNonIComparer ()
+               {
+                       Comparer.Default.Compare (new object (), new object ());
+               }
+
+               [Test]
                public void Invariant ()
                {
                        Comparer c = Comparer.DefaultInvariant;
-
-                       //
-                       // In Mono we are comparing the ordinal values 
-                       // of the strings, while it seems that the MS
-                       // runtime considers lowercase letters like "a"
-                       // to come before "A".
-                       //
-                       // I have not found any documentation on this
-                       // behavior of the InvariantCulture
-                       //
                        Assert.IsTrue (c.Compare ("a", "A") < 0);
                }
 
@@ -65,5 +62,49 @@
                {
                        Assert.IsTrue 
(CultureInfo.InvariantCulture.CompareInfo.Compare ("a", "A", 
CompareOptions.Ordinal) > 0);
                }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void Constructor_Null ()
+               {
+                       new Comparer (null);
+               }
+
+               [Test]
+               public void Constructor ()
+               {
+                       Comparer c = new Comparer 
(CultureInfo.InvariantCulture);
+                       Assert.IsTrue (c.Compare ("a", "A") < 0);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void GetObjectData_Null ()
+               {
+                       Comparer c = Comparer.DefaultInvariant;
+                       c.GetObjectData (null, new StreamingContext ());
+               }
+
+               [Test]
+               public void GetObjectData ()
+               {
+                       Comparer c = Comparer.DefaultInvariant;
+                       SerializationInfo si = new SerializationInfo (typeof 
(Comparer), new FormatterConverter ());
+                       c.GetObjectData (si, new StreamingContext ());
+                       foreach (SerializationEntry se in si) {
+                               switch (se.Name) {
+                               case "CompareInfo":
+                                       CompareInfo ci = (se.Value as 
CompareInfo);
+                                       Assert.IsNotNull (ci, "CompareInfo");
+                                       Assert.AreEqual (127, ci.LCID, "LCID");
+                                       break;
+                               default:
+                                       string msg = String.Format ("Unexpected 
{0} information of type {1} with value '{2}'.",
+                                               se.Name, se.ObjectType, 
se.Value);
+                                       Assert.Fail (msg);
+                                       break;
+                               }
+                       }
+               }
        }
 }

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

Reply via email to