Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / enum.cs
1 using System;
2 using System.Collections.Generic;
3
4 namespace Test {
5
6         enum ByteEnum : byte {
7                 A = 10
8         }
9
10         enum SByteEnum : sbyte {
11                 A = -11
12         }
13
14         enum ShortEnum : short {
15                 A = -12
16         }
17
18         enum UShortEnum : ushort {
19                 A = 13
20         }
21
22         enum IntEnum : int {
23                 A = -15
24         }
25
26         enum UIntEnum : uint {
27                 A = 16
28         }
29
30         enum LongEnum : long {
31                 A = -153453525432334L
32         }
33
34         enum ULongEnum : ulong {
35                 A = 164923797563459L
36         }
37
38         public enum YaddaYadda {
39                 buba,
40                 birba,
41                 dadoom,
42         };
43
44         public enum byteenum : byte {
45                 zero,
46                 one,
47                 two,
48                 three
49         }
50
51         public enum longenum: long {
52                 s0 = 0,
53                 s1 = 1
54         }
55
56         public enum sbyteenum : sbyte {
57                 d0,
58                 d1
59         }
60
61         public class Tests {
62                 public static int test_0_basic_enum_vals ()
63                 {
64                         YaddaYadda val = YaddaYadda.dadoom;
65                         byteenum be = byteenum.one;
66                         if (val != YaddaYadda.dadoom)
67                                 return 1;
68                         if (be != (byteenum)1)
69                                 return 2;
70                         return 0;
71                 }
72
73                 public static int test_0_byte_enum_hashcode ()
74                 {
75                         if (ByteEnum.A.GetHashCode () != EqualityComparer<ByteEnum>.Default.GetHashCode (ByteEnum.A))
76                                 return 1;
77                         if (ByteEnum.A.GetHashCode () != ((byte)ByteEnum.A).GetHashCode () )
78                                 return 2;
79                         return 0;
80                 }
81
82                 public static int test_0_sbyte_enum_hashcode ()
83                 {
84                         if (SByteEnum.A.GetHashCode () != EqualityComparer<SByteEnum>.Default.GetHashCode (SByteEnum.A))
85                                 return 1;
86                         if (SByteEnum.A.GetHashCode () != ((sbyte)SByteEnum.A).GetHashCode () )
87                                 return 2;
88                         return 0;
89                 }
90
91                 public static int test_0_short_enum_hashcode ()
92                 {
93                         if (ShortEnum.A.GetHashCode () != EqualityComparer<ShortEnum>.Default.GetHashCode (ShortEnum.A))
94                                 return 1;
95                         if (ShortEnum.A.GetHashCode () != ((short)ShortEnum.A).GetHashCode () )
96                                 return 2;
97                         return 0;
98                 }
99
100                 public static int test_0_ushort_enum_hashcode ()
101                 {
102                         if (UShortEnum.A.GetHashCode () != EqualityComparer<UShortEnum>.Default.GetHashCode (UShortEnum.A))
103                                 return 1;
104                         if (UShortEnum.A.GetHashCode () != ((ushort)UShortEnum.A).GetHashCode () )
105                                 return 2;
106                         return 0;
107                 }
108
109                 public static int test_0_int_enum_hashcode ()
110                 {
111                         if (IntEnum.A.GetHashCode () != EqualityComparer<IntEnum>.Default.GetHashCode (IntEnum.A))
112                                 return 1;
113                         if (IntEnum.A.GetHashCode () != ((int)IntEnum.A).GetHashCode () )
114                                 return 2;
115                         return 0;
116                 }
117
118                 public static int test_0_uint_enum_hashcode ()
119                 {
120                         if (UIntEnum.A.GetHashCode () != EqualityComparer<UIntEnum>.Default.GetHashCode (UIntEnum.A))
121                                 return 1;
122                         if (UIntEnum.A.GetHashCode () != ((uint)UIntEnum.A).GetHashCode () )
123                                 return 2;
124                         return 0;
125                 }
126
127                 public static int test_0_long_enum_hashcode ()
128                 {
129                         if (LongEnum.A.GetHashCode () != EqualityComparer<LongEnum>.Default.GetHashCode (LongEnum.A))
130                                 return 1;
131                         if (LongEnum.A.GetHashCode () != ((long)LongEnum.A).GetHashCode () )
132                                 return 2;
133                         return 0;
134                 }
135
136                 public static int test_0_ulong_enum_hashcode ()
137                 {
138                         if (ULongEnum.A.GetHashCode () != EqualityComparer<ULongEnum>.Default.GetHashCode (ULongEnum.A))
139                                 return 1;
140                         if (ULongEnum.A.GetHashCode () != ((ulong)ULongEnum.A).GetHashCode () )
141                                 return 2;
142                         return 0;
143                 }
144
145                 public static int Main (String[] args) {
146                         return TestDriver.RunTests (typeof (Tests), args);
147                 }
148
149         }
150
151 }