[netcore] Ongoing work. (#13391)
[mono-project.git] / mono / tests / enum.cs
blobfa65a2c6f74a99808858fae0cd6918c90141726f
1 using System;
2 using System.Collections.Generic;
4 namespace Test {
6 enum ByteEnum : byte {
7 A = 10
10 enum SByteEnum : sbyte {
11 A = -11
14 enum ShortEnum : short {
15 A = -12
18 enum UShortEnum : ushort {
19 A = 13
22 enum IntEnum : int {
23 A = -15
26 enum UIntEnum : uint {
27 A = 16
30 enum LongEnum : long {
31 A = -153453525432334L
34 enum ULongEnum : ulong {
35 A = 164923797563459L
38 public enum YaddaYadda {
39 buba,
40 birba,
41 dadoom,
44 public enum byteenum : byte {
45 zero,
46 one,
47 two,
48 three
51 public enum longenum: long {
52 s0 = 0,
53 s1 = 1
56 public enum sbyteenum : sbyte {
57 d0,
61 public class Tests {
62 public static int test_0_basic_enum_vals ()
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;
73 public static int test_0_byte_enum_hashcode ()
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;
82 public static int test_0_sbyte_enum_hashcode ()
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;
91 public static int test_0_short_enum_hashcode ()
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;
100 public static int test_0_ushort_enum_hashcode ()
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;
109 public static int test_0_int_enum_hashcode ()
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;
118 public static int test_0_uint_enum_hashcode ()
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;
127 public static int test_0_long_enum_hashcode ()
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;
136 public static int test_0_ulong_enum_hashcode ()
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;
145 public static int Main (String[] args) {
146 return TestDriver.RunTests (typeof (Tests), args);