[mono/tests] Fix out of tree build.
[mono-project.git] / mcs / tests / test-646.cs
blobe3df3fd59c38187a80b5a24c8835cb5b6953d6f8
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 public 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;