[netcore] Ongoing work. (#13391)
[mono-project.git] / mono / tests / valuetype-equals.cs
blobcd676061ec5984cad8b86d861e5724cdbe40cf50
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; }
64 unsafe struct PointerStruct {
65 int* x;
66 public PointerStruct (int* x) { this.x = x; }
69 public class Driver {
70 static void AssertEqual (object a, object b) {
71 if (!a.Equals (b))
72 throw new Exception (String.Format ("must be equal {0} {1}", a, b));
75 static void AssertNotEqual (object a, object b) {
76 if (a.Equals (b))
77 throw new Exception (String.Format ("must not be equal {0} {1}", a, b));
80 public static unsafe int Main () {
81 AssertEqual (new BoolStruct (true), new BoolStruct (true));
82 AssertNotEqual (new BoolStruct (false), new BoolStruct (true));
84 AssertEqual (new CharStruct ('c'), new CharStruct ('c'));
85 AssertNotEqual (new CharStruct ('d'), new CharStruct ('c'));
87 AssertEqual (new Int8Struct (13), new Int8Struct (13));
88 AssertEqual (new Int8Struct (0), new Int8Struct (0));
89 AssertNotEqual (new Int8Struct (44), new Int8Struct (1));
90 AssertNotEqual (new Int8Struct (0), new Int8Struct (55));
92 AssertEqual (new UInt8Struct (13), new UInt8Struct (13));
93 AssertEqual (new UInt8Struct (0), new UInt8Struct (0));
94 AssertNotEqual (new UInt8Struct (44), new UInt8Struct (1));
95 AssertNotEqual (new UInt8Struct (0), new UInt8Struct (55));
97 AssertEqual (new Int16Struct (13), new Int16Struct (13));
98 AssertEqual (new Int16Struct (0), new Int16Struct (0));
99 AssertNotEqual (new Int16Struct (44), new Int16Struct (1));
100 AssertNotEqual (new Int16Struct (0), new Int16Struct (55));
102 AssertEqual (new UInt16Struct (13), new UInt16Struct (13));
103 AssertEqual (new UInt16Struct (0), new UInt16Struct (0));
104 AssertNotEqual (new UInt16Struct (44), new UInt16Struct (1));
105 AssertNotEqual (new UInt16Struct (0), new UInt16Struct (55));
107 AssertEqual (new Int32Struct (13), new Int32Struct (13));
108 AssertEqual (new Int32Struct (0), new Int32Struct (0));
109 AssertNotEqual (new Int32Struct (44), new Int32Struct (1));
110 AssertNotEqual (new Int32Struct (0), new Int32Struct (55));
112 AssertEqual (new UInt32Struct (13), new UInt32Struct (13));
113 AssertEqual (new UInt32Struct (0), new UInt32Struct (0));
114 AssertNotEqual (new UInt32Struct (44), new UInt32Struct (1));
115 AssertNotEqual (new UInt32Struct (0), new UInt32Struct (55));
117 AssertEqual (new Int64Struct (13), new Int64Struct (13));
118 AssertEqual (new Int64Struct (0), new Int64Struct (0));
119 AssertNotEqual (new Int64Struct (44), new Int64Struct (1));
120 AssertNotEqual (new Int64Struct (0), new Int64Struct (55));
122 AssertEqual (new UInt64Struct (13), new UInt64Struct (13));
123 AssertEqual (new UInt64Struct (0), new UInt64Struct (0));
124 AssertNotEqual (new UInt64Struct (44), new UInt64Struct (1));
125 AssertNotEqual (new UInt64Struct (0), new UInt64Struct (55));
127 AssertEqual (new FloatStruct (13), new FloatStruct (13));
128 AssertEqual (new FloatStruct (0), new FloatStruct (0));
129 AssertNotEqual (new FloatStruct (44), new FloatStruct (1));
130 AssertNotEqual (new FloatStruct (0), new FloatStruct (55));
132 AssertEqual (new DoubleStruct (13), new DoubleStruct (13));
133 AssertEqual (new DoubleStruct (0), new DoubleStruct (0));
134 AssertNotEqual (new DoubleStruct (44), new DoubleStruct (1));
135 AssertNotEqual (new DoubleStruct (0), new DoubleStruct (55));
137 AssertEqual (new PointerStruct ((int*)(IntPtr)13), new PointerStruct ((int*)(IntPtr)13));
138 AssertEqual (new PointerStruct ((int*)(IntPtr)0), new PointerStruct ((int*)(IntPtr)0));
139 AssertNotEqual (new PointerStruct ((int*)(IntPtr)44), new PointerStruct ((int*)(IntPtr)1));
140 AssertNotEqual (new PointerStruct ((int*)(IntPtr)0), new PointerStruct ((int*)(IntPtr)55));
142 return 0;