Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / tests / test-646.cs
1 using System;
2
3 // Undocumented IntPtr and UIntPtr conversion exceptions
4
5 class Program
6 {
7         static long CastUIntPtrToInt64 (UIntPtr ptr)
8         {
9                 return (long) ptr;
10         }
11         
12         static uint CastIntPtrToUInt32 (IntPtr ptr)
13         {
14                 return (uint) ptr;
15         }
16         
17         public static int Main ()
18         {
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;
27                                 
28                         if (CastIntPtrToUInt32 (new IntPtr (long.MaxValue)) != uint.MaxValue)
29                                 return 4;
30                 }
31                 
32                 return 0;
33         }
34 }