2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / corlib / Test / System / UIntPtrTest.cs
1 // 
2 // System.UIntPtrTest.cs - Unit test for UIntPtr
3 //
4 // Author
5 //      Sebastien Pouliot  <sebastien@ximian.com>
6 //
7 // Copyright (C) 2004 Novell (http://www.novell.com)
8 //
9
10 using System;
11 using NUnit.Framework;
12
13 namespace MonoTests.System  {
14
15         [TestFixture]
16         public class UIntPtrTest : Assertion {
17
18                 [Test]
19                 [ExpectedException (typeof (OverflowException))]
20                 public void Test64on32 () 
21                 {
22                         if (UIntPtr.Size > 4)
23                                 throw new OverflowException ("Test only applicable to 32bits machines");
24
25                         ulong addr = UInt32.MaxValue;
26                         UIntPtr p = new UIntPtr (addr + 1);
27                 }
28
29                 [Test]
30                 public void TestUlongOn32 ()
31                 {
32                         // int64 can be used (as a type) with a 32bits address
33                         ulong max32 = UInt32.MaxValue;
34                         UIntPtr p32max = new UIntPtr (max32);
35
36                         ulong min32 = UInt32.MinValue;
37                         UIntPtr p32min = new UIntPtr (min32);
38                 }
39
40                 [Test]
41                 public void Test64on64 () 
42                 {
43                         // for 64 bits machines
44                         if (UIntPtr.Size > 4) {
45                                 UIntPtr pmax = new UIntPtr (UInt64.MaxValue);
46                                 AssertEquals ("Max", UInt64.MaxValue, (ulong) pmax);
47
48                                 UIntPtr pmin = new UIntPtr (UInt64.MinValue);
49                                 AssertEquals ("Min", UInt64.MinValue, (ulong) pmin);
50                         }
51                 }
52         }
53 }