2009-06-26 Robert Jordan <robertj@gmx.net>
authorRobert Jordan <robertj@gmx.net>
Fri, 26 Jun 2009 08:36:55 +0000 (08:36 -0000)
committerRobert Jordan <robertj@gmx.net>
Fri, 26 Jun 2009 08:36:55 +0000 (08:36 -0000)
* BitArrayTest.cs: Upgrade to new NUnit style. Enable
16 tests that were disabled after the NUnit 2.4 update.

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

mcs/class/corlib/Test/System.Collections/BitArrayTest.cs
mcs/class/corlib/Test/System.Collections/ChangeLog

index 1379433181190e01518ea59c51868e12439156f9..fb3725ac12b0cb72807eec396c01cc6c59da998c 100644 (file)
@@ -10,8 +10,8 @@ using System;
 
 namespace MonoTests.System.Collections
 {
-
-public class BitArrayTest : TestCase 
+[TestFixture]
+public class BitArrayTest
 {
   private BitArray testBa;
   private bool [] testPattern;
@@ -20,12 +20,13 @@ public class BitArrayTest : TestCase
 
   private void verifyPattern(BitArray ba, bool[] pattern)
   {
-    AssertEquals(ba.Length, pattern.Length);
+    Assert.AreEqual (ba.Length, pattern.Length);
     for (int i = 0; i < pattern.Length; i++)
-      AssertEquals(ba[i], pattern[i]);
+      Assert.AreEqual (ba[i], pattern[i]);
   }
 
-  protected override void SetUp()
+  [SetUp]
+  public void SetUp()
   {
     testPattern = new bool[70];
 
@@ -46,12 +47,14 @@ public class BitArrayTest : TestCase
     op2 = new BitArray(new int[] { 0x66666666, 0x66666666 });
   }
   
+  [Test]
   public void TestBoolConstructor()
   {
     BitArray ba = new BitArray(testPattern);
     verifyPattern(ba, testPattern);
   }
 
+  [Test]
   public void TestCopyConstructor() 
   {
     BitArray ba = new BitArray(testBa);
@@ -59,55 +62,59 @@ public class BitArrayTest : TestCase
     verifyPattern(ba, testPattern);
   }
 
+  [Test]
   public void TestByteConstructor()
   {
     byte [] byteArr = new byte[] { 0xaa, 0x55, 0xaa, 0x55, 0x80 };
     BitArray ba = new BitArray(byteArr);
     
-    AssertEquals("Lengths not equal", ba.Length, byteArr.Length * 8);
+    Assert.AreEqual (ba.Length, byteArr.Length * 8, "Lengths not equal");
     
     // spot check
-    Assert("7 not true", ba[7]);
-    Assert("6 not false", !ba[6]);
-    Assert("15 not false", !ba[15]);
-    Assert("14 not true", ba[14]);
-    Assert("39 not true", ba[39]);
-    Assert("35 not false", !ba[35]);
+    Assert.IsTrue (ba[7], "7 not true");
+    Assert.IsTrue (!ba[6], "6 not false");
+    Assert.IsTrue (!ba[15], "15 not false");
+    Assert.IsTrue (ba[14], "14 not true");
+    Assert.IsTrue (ba[39], "39 not true");
+    Assert.IsTrue (!ba[35], "35 not false");
 
   }
 
+  [Test]
   public void TestIntConstructor()
   {
     int [] intArr = new int[] { ~0x55555555, 0x55555551 };
     BitArray ba = new BitArray(intArr);
     
-    AssertEquals(ba.Length, intArr.Length * 32);
+    Assert.AreEqual (ba.Length, intArr.Length * 32);
     
     // spot check
     
-    Assert(ba[31]);
-    Assert(!ba[30]);
-    Assert(!ba[63]);
-    Assert(ba[62]);
-    Assert(ba[32]);
-    Assert(!ba[35]);
+    Assert.IsTrue (ba[31]);
+    Assert.IsTrue (!ba[30]);
+    Assert.IsTrue (!ba[63]);
+    Assert.IsTrue (ba[62]);
+    Assert.IsTrue (ba[32]);
+    Assert.IsTrue (!ba[35]);
   }
 
+  [Test]
   public void TestValConstructor()
   {
     BitArray ba = new BitArray(64, false);
 
-    AssertEquals(ba.Length, 64);
+    Assert.AreEqual (ba.Length, 64);
     foreach (bool b in ba)
-      Assert(!b);
+      Assert.IsTrue (!b);
 
     ba = new BitArray(64, true);
 
-    AssertEquals(ba.Length, 64);
+    Assert.AreEqual (ba.Length, 64);
     foreach (bool b in ba)
-      Assert(b);
+      Assert.IsTrue (b);
   }
 
+  [Test]
   public void TestClone()
   {
     BitArray ba = (BitArray)testBa.Clone();
@@ -122,12 +129,13 @@ public class BitArrayTest : TestCase
     verifyPattern(testBa, testPattern);
   }
   
+  [Test]
   public void TestSetLength()
   {
     int origLen = testBa.Length;
     testBa.Length += 33;
 
-    AssertEquals(origLen + 33, testBa.Length);
+    Assert.AreEqual (origLen + 33, testBa.Length);
     for (int i = origLen; i < testBa.Length; i++)
       testBa[i] = true;
 
@@ -135,68 +143,74 @@ public class BitArrayTest : TestCase
     verifyPattern(testBa, testPattern);
   }
 
+  [Test]
   public void TestAnd()
   {
     BitArray result = op1.And(op2);
-    AssertEquals(result.Length, op1.Length);
+    Assert.AreEqual (result.Length, op1.Length);
     for (int i = 0; i < result.Length; )
     {
-      Assert(!result[i++]);
-      Assert(result[i++]);
-      Assert(!result[i++]);
-      Assert(!result[i++]);
+      Assert.IsTrue (!result[i++]);
+      Assert.IsTrue (result[i++]);
+      Assert.IsTrue (!result[i++]);
+      Assert.IsTrue (!result[i++]);
     }
   }
 
+  [Test]
   public void TestOr()
   {
     BitArray result = op1.Or(op2);
-    AssertEquals(result.Length, op1.Length);
+    Assert.AreEqual (result.Length, op1.Length);
     for (int i = 0; i < result.Length; )
     {
-      Assert(result[i++]);
-      Assert(result[i++]);
-      Assert(result[i++]);
-      Assert(!result[i++]);
+      Assert.IsTrue (result[i++]);
+      Assert.IsTrue (result[i++]);
+      Assert.IsTrue (result[i++]);
+      Assert.IsTrue (!result[i++]);
     }
   }
 
+  [Test]
   public void TestNot()
   {
     BitArray result = op1.Not();
-    AssertEquals(result.Length, op1.Length);
+    Assert.AreEqual (result.Length, op1.Length);
     for (int i = 0; i < result.Length; )
     {
-      Assert(!result[i++]);
-      Assert(!result[i++]);
-      Assert(result[i++]);
-      Assert(result[i++]);
+      Assert.IsTrue (!result[i++]);
+      Assert.IsTrue (!result[i++]);
+      Assert.IsTrue (result[i++]);
+      Assert.IsTrue (result[i++]);
     }
   }
 
+  [Test]
   public void TestXor()
   {
     BitArray result = op1.Xor(op2);
-    AssertEquals(result.Length, op1.Length);
+    Assert.AreEqual (result.Length, op1.Length);
     for (int i = 0; i < result.Length; )
     {
-      Assert(result[i++]);
-      Assert(!result[i++]);
-      Assert(result[i++]);
-      Assert(!result[i++]);
+      Assert.IsTrue (result[i++]);
+      Assert.IsTrue (!result[i++]);
+      Assert.IsTrue (result[i++]);
+      Assert.IsTrue (!result[i++]);
     }
   }
 
+  [Test]
   public void TestSetAll()
   {
     testBa.SetAll(false);
     foreach(bool b in testBa)
-      Assert(!b);
+      Assert.IsTrue (!b);
     testBa.SetAll(true);
     foreach(bool b in testBa)
-      Assert(b);
+      Assert.IsTrue (b);
   }
 
+  [Test]
   public void TestCopyToBool()
   {
     try {
@@ -205,10 +219,10 @@ public class BitArrayTest : TestCase
            testBa.CopyTo(barray, 5);
 
            for (int i = 0; i < testBa.Length; i++)
-             AssertEquals(testBa[i], barray[i+5]);
+             Assert.AreEqual (testBa[i], barray[i+5]);
     }
     catch(Exception e){
-       Fail("Unexpected exception thrown: " + e.ToString());
+       Assert.Fail ("Unexpected exception thrown: " + e.ToString());
     }
   }
 
@@ -221,6 +235,7 @@ public class BitArrayTest : TestCase
          bitarray.CopyTo(intarray, 0);
   }
 
+  [Test]
   public void TestCopyToByte()
   {
     try {
@@ -230,7 +245,7 @@ public class BitArrayTest : TestCase
            testBa.CopyTo(barray, 5);
 
            for (int i = 5; i < 9; i++)
-             AssertEquals(0x55, barray[i] & 0xff);
+             Assert.AreEqual (0x55, barray[i] & 0xff);
 
            // FIXME: MS fails on the next line.  This is because
            // we truncated testBa.Length, and MS's internal array still
@@ -238,13 +253,14 @@ public class BitArrayTest : TestCase
            // whether the "junk" bits (bits past Length, but within Length
            // rounded up to 32) will be copied as 0, or if those bits are
            // undefined.
-           //AssertEquals(0x01, barray[9] & 0xff);
+           //Assert.AreEqual (0x01, barray[9] & 0xff);
     }
     catch(Exception e){
-       Fail("Unexpected exception thrown: " + e.ToString());
+       Assert.Fail ("Unexpected exception thrown: " + e.ToString());
     }
   }
 
+  [Test]
   public void TestCopyToInt()
   {
     try {
@@ -253,15 +269,16 @@ public class BitArrayTest : TestCase
            
            testBa.CopyTo(iarray, 5);
 
-           AssertEquals(0x55555555, iarray[5]);
+           Assert.AreEqual (0x55555555, iarray[5]);
            // FIXME:  Same thing here as in TestCopyToByte
-           //AssertEquals(0x01, iarray[6]);
+           //Assert.AreEqual (0x01, iarray[6]);
     }
     catch(Exception e){
-       Fail("Unexpected exception thrown: " + e.ToString());
+       Assert.Fail ("Unexpected exception thrown: " + e.ToString());
     }
   }
 
+  [Test]
   public void TestEnumerator()
   {
     
@@ -269,29 +286,29 @@ public class BitArrayTest : TestCase
            IEnumerator e = testBa.GetEnumerator();
            
            for (int i = 0; e.MoveNext(); i++)
-             AssertEquals(e.Current, testPattern[i]);
+             Assert.AreEqual (e.Current, testPattern[i]);
 
-           Assert(!e.MoveNext());
+           Assert.IsTrue (!e.MoveNext());
            // read, to make sure reading isn't considered a write.
            bool b = testBa[0];
 
            e.Reset();
            for (int i = 0; e.MoveNext(); i++)
-             AssertEquals(e.Current, testPattern[i]);
+             Assert.AreEqual (e.Current, testPattern[i]);
 
            try
            {
              e.Reset();
              testBa[0] = !testBa[0];
              e.MoveNext();
-             Fail("IEnumerator.MoveNext() should throw when collection modified.");
+             Assert.Fail ("IEnumerator.MoveNext() should throw when collection modified.");
            }
            catch (InvalidOperationException)
            {
            }
     }
     catch(Exception ex){
-       Fail("Unexpected exception thrown: " + ex.ToString());
+       Assert.Fail ("Unexpected exception thrown: " + ex.ToString());
     }
   }
 }
index 5ae6b0c756ed788736e303debee7ccf0a3707c4b..e8c6ccec0c596e2638ace4cf09b5b280ca0ef876 100644 (file)
@@ -1,3 +1,8 @@
+2009-06-26  Robert Jordan  <robertj@gmx.net>
+
+       * BitArrayTest.cs: Upgrade to new NUnit style. Enable
+       16 tests that were disabled after the NUnit 2.4 update.
+
 2009-06-24  Robert Jordan  <robertj@gmx.net>
 
        * ArrayListTest.cs, CollectionBaseTest.cs, DictionaryEntryTest.cs,