X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Ftests%2Fenum.cs;h=fa65a2c6f74a99808858fae0cd6918c90141726f;hb=ac1d494270ac25b3fd885ef7d8b52cb27109861d;hp=2f8f55cd53abcc3b48cbbdeee2f1fdfaf677f757;hpb=c4a3b30460c7ea1a1fb3c97cfc8478555714af2f;p=mono.git diff --git a/mono/tests/enum.cs b/mono/tests/enum.cs index 2f8f55cd53a..fa65a2c6f74 100644 --- a/mono/tests/enum.cs +++ b/mono/tests/enum.cs @@ -1,38 +1,151 @@ +using System; +using System.Collections.Generic; + namespace Test { -public enum YaddaYadda { - buba, - birba, - dadoom, -}; - -public enum byteenum : byte { - zero, - one, - two, - three -} + enum ByteEnum : byte { + A = 10 + } -public enum longenum: long { - s0 = 0, - s1 = 1 -} + enum SByteEnum : sbyte { + A = -11 + } -public enum sbyteenum : sbyte { - d0, - d1 -} + enum ShortEnum : short { + A = -12 + } + + enum UShortEnum : ushort { + A = 13 + } + + enum IntEnum : int { + A = -15 + } + + enum UIntEnum : uint { + A = 16 + } + + enum LongEnum : long { + A = -153453525432334L + } + + enum ULongEnum : ulong { + A = 164923797563459L + } + + public enum YaddaYadda { + buba, + birba, + dadoom, + }; + + public enum byteenum : byte { + zero, + one, + two, + three + } + + public enum longenum: long { + s0 = 0, + s1 = 1 + } + + public enum sbyteenum : sbyte { + d0, + d1 + } + + public class Tests { + public static int test_0_basic_enum_vals () + { + YaddaYadda val = YaddaYadda.dadoom; + byteenum be = byteenum.one; + if (val != YaddaYadda.dadoom) + return 1; + if (be != (byteenum)1) + return 2; + return 0; + } + + public static int test_0_byte_enum_hashcode () + { + if (ByteEnum.A.GetHashCode () != EqualityComparer.Default.GetHashCode (ByteEnum.A)) + return 1; + if (ByteEnum.A.GetHashCode () != ((byte)ByteEnum.A).GetHashCode () ) + return 2; + return 0; + } + + public static int test_0_sbyte_enum_hashcode () + { + if (SByteEnum.A.GetHashCode () != EqualityComparer.Default.GetHashCode (SByteEnum.A)) + return 1; + if (SByteEnum.A.GetHashCode () != ((sbyte)SByteEnum.A).GetHashCode () ) + return 2; + return 0; + } + + public static int test_0_short_enum_hashcode () + { + if (ShortEnum.A.GetHashCode () != EqualityComparer.Default.GetHashCode (ShortEnum.A)) + return 1; + if (ShortEnum.A.GetHashCode () != ((short)ShortEnum.A).GetHashCode () ) + return 2; + return 0; + } + + public static int test_0_ushort_enum_hashcode () + { + if (UShortEnum.A.GetHashCode () != EqualityComparer.Default.GetHashCode (UShortEnum.A)) + return 1; + if (UShortEnum.A.GetHashCode () != ((ushort)UShortEnum.A).GetHashCode () ) + return 2; + return 0; + } + + public static int test_0_int_enum_hashcode () + { + if (IntEnum.A.GetHashCode () != EqualityComparer.Default.GetHashCode (IntEnum.A)) + return 1; + if (IntEnum.A.GetHashCode () != ((int)IntEnum.A).GetHashCode () ) + return 2; + return 0; + } + + public static int test_0_uint_enum_hashcode () + { + if (UIntEnum.A.GetHashCode () != EqualityComparer.Default.GetHashCode (UIntEnum.A)) + return 1; + if (UIntEnum.A.GetHashCode () != ((uint)UIntEnum.A).GetHashCode () ) + return 2; + return 0; + } + + public static int test_0_long_enum_hashcode () + { + if (LongEnum.A.GetHashCode () != EqualityComparer.Default.GetHashCode (LongEnum.A)) + return 1; + if (LongEnum.A.GetHashCode () != ((long)LongEnum.A).GetHashCode () ) + return 2; + return 0; + } + + public static int test_0_ulong_enum_hashcode () + { + if (ULongEnum.A.GetHashCode () != EqualityComparer.Default.GetHashCode (ULongEnum.A)) + return 1; + if (ULongEnum.A.GetHashCode () != ((ulong)ULongEnum.A).GetHashCode () ) + return 2; + return 0; + } + + public static int Main (String[] args) { + return TestDriver.RunTests (typeof (Tests), args); + } -public class test { - public static int Main () { - YaddaYadda val = YaddaYadda.dadoom; - byteenum be = byteenum.one; - if (val != YaddaYadda.dadoom) - return 1; - if (be != (byteenum)1) - return 2; - return 0; } -} }