2009-02-15 Jonathan Chambers <joncham@gmail.com>
[mcs.git] / tests / test-646.cs
blob287ba39e715223967c2005854bdb8092a4c1bec1
1 using System;
3 // Undocumented IntPtr and UIntPtr conversion exceptions
5 class Program
7 static long CastUIntPtrToInt64 (UIntPtr ptr)
9 return (long) ptr;
12 static uint CastIntPtrToUInt32 (IntPtr ptr)
14 return (uint) ptr;
17 static int Main ()
19 if (IntPtr.Size < 8) {
20 if (CastUIntPtrToInt64 (new UIntPtr (uint.MaxValue)) != uint.MaxValue)
21 return 1;
22 if (CastIntPtrToUInt32 (new IntPtr (int.MaxValue)) != int.MaxValue)
23 return 2;
24 } else {
25 if (CastUIntPtrToInt64 (new UIntPtr (ulong.MaxValue)) != -1)
26 return 3;
28 if (CastIntPtrToUInt32 (new IntPtr (long.MaxValue)) != uint.MaxValue)
29 return 4;
32 return 0;