2 // System.IntPtrTest.cs - Unit test for IntPtr
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 IntPtrTest : Assertion {
19 [ExpectedException (typeof (OverflowException))]
20 public void Test64on32 ()
23 throw new OverflowException ("Test only applicable to 32bits machines");
25 long addr = Int32.MaxValue;
26 IntPtr p = new IntPtr (addr + 1);
30 public void TestLongOn32 ()
32 // int64 can be used (as a type) with a 32bits address
33 long max32 = Int32.MaxValue;
34 IntPtr p32max = new IntPtr (max32);
36 long min32 = Int32.MinValue;
37 IntPtr p32min = new IntPtr (min32);
41 public void Test64on64 ()
43 // for 64 bits machines
44 if (IntPtr.Size > 4) {
45 IntPtr pmax = new IntPtr (Int64.MaxValue);
46 AssertEquals ("Max", Int64.MaxValue, (long) pmax);
48 IntPtr pmin = new IntPtr (Int64.MinValue);
49 AssertEquals ("Min", Int64.MinValue, (long) pmin);