2010-06-17 Geoff Norton <gnorton@novell.com>
[mono.git] / mono / tests / valuetype-equals.cs
blob243023fd64e3dacf862908a830b1d710f2fdeb32
1 using System;
4 struct BoolStruct {
5 bool x;
6 public BoolStruct (bool x) { this.x = x; }
9 struct CharStruct {
10 char x;
11 public CharStruct (char x) { this.x = x; }
14 struct Int8Struct {
15 sbyte x;
16 public Int8Struct (sbyte x) { this.x = x; }
19 struct UInt8Struct {
20 byte x;
21 public UInt8Struct (byte x) { this.x = x; }
24 struct Int16Struct {
25 short x;
26 public Int16Struct (short x) { this.x = x; }
29 struct UInt16Struct {
30 ushort x;
31 public UInt16Struct (ushort x) { this.x = x; }
34 struct Int32Struct {
35 int x;
36 public Int32Struct (int x) { this.x = x; }
39 struct UInt32Struct {
40 uint x;
41 public UInt32Struct (uint x) { this.x = x; }
44 struct Int64Struct {
45 long x;
46 public Int64Struct (long x) { this.x = x; }
49 struct UInt64Struct {
50 ulong x;
51 public UInt64Struct (ulong x) { this.x = x; }
54 struct FloatStruct {
55 float x;
56 public FloatStruct (float x) { this.x = x; }
59 struct DoubleStruct {
60 double x;
61 public DoubleStruct (double x) { this.x = x; }
65 public class Driver {
66 static void AssertEqual (object a, object b) {
67 if (!a.Equals (b))
68 throw new Exception (String.Format ("must be equal {0} {1}", a, b));
71 static void AssertNotEqual (object a, object b) {
72 if (a.Equals (b))
73 throw new Exception (String.Format ("must not be equal {0} {1}", a, b));
76 public static int Main () {
77 AssertEqual (new BoolStruct (true), new BoolStruct (true));
78 AssertNotEqual (new BoolStruct (false), new BoolStruct (true));
80 AssertEqual (new CharStruct ('c'), new CharStruct ('c'));
81 AssertNotEqual (new CharStruct ('d'), new CharStruct ('c'));
83 AssertEqual (new Int8Struct (13), new Int8Struct (13));
84 AssertEqual (new Int8Struct (0), new Int8Struct (0));
85 AssertNotEqual (new Int8Struct (44), new Int8Struct (1));
86 AssertNotEqual (new Int8Struct (0), new Int8Struct (55));
88 AssertEqual (new UInt8Struct (13), new UInt8Struct (13));
89 AssertEqual (new UInt8Struct (0), new UInt8Struct (0));
90 AssertNotEqual (new UInt8Struct (44), new UInt8Struct (1));
91 AssertNotEqual (new UInt8Struct (0), new UInt8Struct (55));
93 AssertEqual (new Int16Struct (13), new Int16Struct (13));
94 AssertEqual (new Int16Struct (0), new Int16Struct (0));
95 AssertNotEqual (new Int16Struct (44), new Int16Struct (1));
96 AssertNotEqual (new Int16Struct (0), new Int16Struct (55));
98 AssertEqual (new UInt16Struct (13), new UInt16Struct (13));
99 AssertEqual (new UInt16Struct (0), new UInt16Struct (0));
100 AssertNotEqual (new UInt16Struct (44), new UInt16Struct (1));
101 AssertNotEqual (new UInt16Struct (0), new UInt16Struct (55));
103 AssertEqual (new Int32Struct (13), new Int32Struct (13));
104 AssertEqual (new Int32Struct (0), new Int32Struct (0));
105 AssertNotEqual (new Int32Struct (44), new Int32Struct (1));
106 AssertNotEqual (new Int32Struct (0), new Int32Struct (55));
108 AssertEqual (new UInt32Struct (13), new UInt32Struct (13));
109 AssertEqual (new UInt32Struct (0), new UInt32Struct (0));
110 AssertNotEqual (new UInt32Struct (44), new UInt32Struct (1));
111 AssertNotEqual (new UInt32Struct (0), new UInt32Struct (55));
113 AssertEqual (new Int64Struct (13), new Int64Struct (13));
114 AssertEqual (new Int64Struct (0), new Int64Struct (0));
115 AssertNotEqual (new Int64Struct (44), new Int64Struct (1));
116 AssertNotEqual (new Int64Struct (0), new Int64Struct (55));
118 AssertEqual (new UInt64Struct (13), new UInt64Struct (13));
119 AssertEqual (new UInt64Struct (0), new UInt64Struct (0));
120 AssertNotEqual (new UInt64Struct (44), new UInt64Struct (1));
121 AssertNotEqual (new UInt64Struct (0), new UInt64Struct (55));
123 AssertEqual (new FloatStruct (13), new FloatStruct (13));
124 AssertEqual (new FloatStruct (0), new FloatStruct (0));
125 AssertNotEqual (new FloatStruct (44), new FloatStruct (1));
126 AssertNotEqual (new FloatStruct (0), new FloatStruct (55));
128 AssertEqual (new DoubleStruct (13), new DoubleStruct (13));
129 AssertEqual (new DoubleStruct (0), new DoubleStruct (0));
130 AssertNotEqual (new DoubleStruct (44), new DoubleStruct (1));
131 AssertNotEqual (new DoubleStruct (0), new DoubleStruct (55));
133 return 0;