2 // System.UIntPtrTest.cs - Unit test for UIntPtr
5 // Sebastien Pouliot <sebastien@ximian.com>
7 // Copyright (C) 2004 Novell (http://www.novell.com)
11 using NUnit.Framework;
13 namespace MonoTests.System {
16 public class UIntPtrTest {
19 [ExpectedException (typeof (OverflowException))]
20 public void Test64on32 ()
23 throw new OverflowException ("Test only applicable to 32bits machines");
25 ulong addr = UInt32.MaxValue;
26 UIntPtr p = new UIntPtr (addr + 1);
30 public void TestUlongOn32 ()
32 // int64 can be used (as a type) with a 32bits address
33 ulong max32 = UInt32.MaxValue;
34 UIntPtr p32max = new UIntPtr (max32);
36 ulong min32 = UInt32.MinValue;
37 UIntPtr p32min = new UIntPtr (min32);
41 public void Test64on64 ()
43 // for 64 bits machines
44 if (UIntPtr.Size > 4) {
45 UIntPtr pmax = new UIntPtr (UInt64.MaxValue);
46 Assert.AreEqual (UInt64.MaxValue, (ulong) pmax, "Max");
48 UIntPtr pmin = new UIntPtr (UInt64.MinValue);
49 Assert.AreEqual (UInt64.MinValue, (ulong) pmin, "Min");
54 public void ToString ()
56 // for 64 bits machines
57 if (UIntPtr.Size > 4) {
58 Assert.AreEqual (UInt64.MaxValue.ToString (), new UIntPtr (UInt64.MaxValue).ToString (), "#1");
61 Assert.AreEqual (UInt32.MaxValue.ToString (), new UIntPtr (UInt32.MaxValue).ToString (), "#2");