2004-05-22 Sebastien Pouliot <sebastien@ximian.com>
authorSebastien Pouliot <sebastien@ximian.com>
Sat, 22 May 2004 14:01:38 +0000 (14:01 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Sat, 22 May 2004 14:01:38 +0000 (14:01 -0000)
* UIntPtrTest.cs: New. Tests for 32/64 bits behaviour of UIntPtr.

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

mcs/class/corlib/Test/System/ChangeLog
mcs/class/corlib/Test/System/UIntPtrTest.cs [new file with mode: 0755]

index 9044882a2118406b83383c20691bc65f4139670c..bab5c9b89a63b0be33980df020614569bb53f16a 100644 (file)
@@ -2,6 +2,7 @@
 
        * IntPtrTest.cs: New. Tests for 32/64 bits behaviour of IntPtr.
        * SingleTest.cs: Added tests to compare positive 0 and negative 0.
+       * UIntPtrTest.cs: New. Tests for 32/64 bits behaviour of UIntPtr.
 
 2004-05-21  Sebastien Pouliot  <sebastien@ximian.com>
 
diff --git a/mcs/class/corlib/Test/System/UIntPtrTest.cs b/mcs/class/corlib/Test/System/UIntPtrTest.cs
new file mode 100755 (executable)
index 0000000..397f4ff
--- /dev/null
@@ -0,0 +1,53 @@
+// 
+// System.UIntPtrTest.cs - Unit test for UIntPtr
+//
+// Author
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// Copyright (C) 2004 Novell (http://www.novell.com)
+//
+
+using System;
+using NUnit.Framework;
+
+namespace MonoTests.System  {
+
+       [TestFixture]
+       public class UIntPtrTest : Assertion {
+
+               [Test]
+               [ExpectedException (typeof (OverflowException))]
+               public void Test64on32 () 
+               {
+                       if (UIntPtr.Size > 4)
+                               throw new OverflowException ("Test only applicable to 32bits machines");
+
+                       ulong addr = UInt32.MaxValue;
+                       UIntPtr p = new UIntPtr (addr + 1);
+               }
+
+               [Test]
+               public void TestUlongOn32 ()
+               {
+                       // int64 can be used (as a type) with a 32bits address
+                       ulong max32 = UInt32.MaxValue;
+                       UIntPtr p32max = new UIntPtr (max32);
+
+                       ulong min32 = UInt32.MinValue;
+                       UIntPtr p32min = new UIntPtr (min32);
+               }
+
+               [Test]
+               public void Test64on64 () 
+               {
+                       // for 64 bits machines
+                       if (UIntPtr.Size > 4) {
+                               UIntPtr pmax = new UIntPtr (UInt64.MaxValue);
+                               AssertEquals ("Max", UInt64.MaxValue, (ulong) pmax);
+
+                               UIntPtr pmin = new UIntPtr (UInt64.MinValue);
+                               AssertEquals ("Min", UInt64.MinValue, (ulong) pmin);
+                       }
+               }
+       }
+}
\ No newline at end of file