2 // This test probes the various explicit unboxing casts
7 static int cast_int (object o) { return (int) o; }
8 static uint cast_uint (object o) { return (uint) o; }
9 static short cast_short (object o) { return (short) o; }
10 static char cast_char (object o) { return (char) o; }
11 static ushort cast_ushort (object o) { return (ushort) o; }
12 static byte cast_byte (object o) { return (byte) o; }
13 static sbyte cast_sbyte (object o) { return (sbyte) o; }
14 static long cast_long (object o) { return (long) o; }
15 static ulong cast_ulong (object o) { return (ulong) o; }
16 static float cast_float (object o) { return (float) o; }
17 static double cast_double (object o) { return (double) o; }
18 static bool cast_bool (object o) { return (bool) o; }
22 if (cast_int ((object) -1) != -1)
24 if (cast_int ((object) 1) != 1)
26 if (cast_int ((object) Int32.MaxValue) != Int32.MaxValue)
28 if (cast_int ((object) Int32.MinValue) != Int32.MinValue)
30 if (cast_int ((object) 0) != 0)
33 if (cast_uint ((object) (uint)0) != 0)
35 if (cast_uint ((object) (uint) 1) != 1)
37 if (cast_uint ((object) (uint) UInt32.MaxValue) != UInt32.MaxValue)
39 if (cast_uint ((object) (uint) UInt32.MinValue) != UInt32.MinValue)
42 if (cast_ushort ((object) (ushort) 1) != 1)
44 if (cast_ushort ((object) (ushort) UInt16.MaxValue) != UInt16.MaxValue)
46 if (cast_ushort ((object) (ushort) UInt16.MinValue) != UInt16.MinValue)
48 if (cast_ushort ((object) (ushort) 0) != 0)
51 if (cast_short ((object) (short)-1) != -1)
53 if (cast_short ((object) (short) 1) != 1)
55 if (cast_short ((object) (short) Int16.MaxValue) != Int16.MaxValue)
57 if (cast_short ((object) (short) Int16.MinValue) != Int16.MinValue)
59 if (cast_short ((object) (short) 0) != 0)
62 if (cast_byte ((object) (byte)1) != 1)
64 if (cast_byte ((object) (byte) Byte.MaxValue) != Byte.MaxValue)
66 if (cast_byte ((object) (byte) Byte.MinValue) != Byte.MinValue)
68 if (cast_byte ((object) (byte) 0) != 0)
71 if (cast_sbyte ((object) (sbyte) -1) != -1)
73 if (cast_sbyte ((object) (sbyte) 1) != 1)
75 if (cast_sbyte ((object) (sbyte) SByte.MaxValue) != SByte.MaxValue)
77 if (cast_sbyte ((object) (sbyte)SByte.MinValue) != SByte.MinValue)
79 if (cast_sbyte ((object) (sbyte) 0) != 0)
83 if (cast_long ((object) (long) -1) != -1)
85 if (cast_long ((object) (long) 1) != 1)
87 if (cast_long ((object) (long) Int64.MaxValue) != Int64.MaxValue)
89 if (cast_long ((object) (long) Int64.MinValue) != Int64.MinValue)
91 if (cast_long ((object) (long) 0) != 0)
94 if (cast_ulong ((object) (ulong) 0) != 0)
96 if (cast_ulong ((object) (ulong) 1) != 1)
98 if (cast_ulong ((object) (ulong) UInt64.MaxValue) != UInt64.MaxValue)
100 if (cast_ulong ((object) (ulong) UInt64.MinValue) != UInt64.MinValue)
103 if (cast_double ((object) (double) -1) != -1)
105 if (cast_double ((object) (double) 1) != 1)
107 if (cast_double ((object) (double) Double.MaxValue) != Double.MaxValue)
109 if (cast_double ((object) (double) Double.MinValue) != Double.MinValue)
111 if (cast_double ((object) (double) 0) != 0)
114 if (cast_float ((object) (float) -1) != -1)
116 if (cast_float ((object) (float) 1) != 1)
118 if (cast_float ((object) (float)Single.MaxValue) != Single.MaxValue)
120 if (cast_float ((object) (float) Single.MinValue) != Single.MinValue)
122 if (cast_float ((object) (float) 0) != 0)