Implemented overloaded versions of Parse and TryParse functions for BigInteger.
[mono.git] / mcs / class / corlib / Test / System / ValueTypeTest.cs
1 //
2 // VersionTest.cs - NUnit Test Cases for the System.ValueType class
3 //
4 // Authors:
5 //      Gonzalo Paniagua Javier (gonzalo@ximian.com)
6 //
7 // (c) 2003 Novell, Inc. (http://www.novell.com)
8 //
9
10 using NUnit.Framework;
11 using System;
12
13 namespace MonoTests.System
14 {
15         struct Blah
16         { 
17                 public string s;
18                 public int x;
19
20                 public Blah (string s, int x)
21                 {
22                         this.s = s;
23                         this.x = x;
24                 }
25         }
26
27         struct Lalala
28         { 
29                 public int x;
30                 public string s;
31
32                 public Lalala (string s, int x)
33                 {
34                         this.s = s;
35                         this.x = x;
36                 }
37         }
38
39         struct NullableStruct {
40                 public Nullable<int> f;
41         }
42
43         [TestFixture]
44         public class ValueTypeTest 
45         {
46                 [Test]
47                 public void TestEquals ()
48                 {
49                         Blah a = new Blah ("abc", 1);
50                         Blah b = new Blah (string.Format ("ab{0}", 'c'), 1);
51                         Assert.AreEqual (a.Equals (b), true, "#01");
52                 }
53
54                 [Test]
55                 public void TestEquals_Nullable ()
56                 {
57                         NullableStruct f1 = new NullableStruct { f = 5 };
58                         NullableStruct f2 = new NullableStruct { f = 5 };
59                         Assert.IsTrue (f1.Equals (f2));
60
61                         f1 = new NullableStruct { f = null };
62                         f2 = new NullableStruct { f = null };
63                         Assert.IsTrue (f1.Equals (f2));
64
65                         f1 = new NullableStruct { f = 1 };
66                         f2 = new NullableStruct { f = 2 };
67                         Assert.IsFalse (f1.Equals (f2));
68
69                         f1 = new NullableStruct { f = 1 };
70                         f2 = new NullableStruct { f = null };
71                         Assert.IsFalse (f1.Equals (f2));
72                 }
73
74                 [Test]
75                 public void TestGetHash ()
76                 {
77                         Blah a = new Blah ("abc", 1);
78                         Blah b = new Blah (string.Format ("ab{0}", 'c'), 1);
79                         Assert.AreEqual (a.GetHashCode (), b.GetHashCode (), "#01");
80
81                         Lalala la = new Lalala ("abc", 1);
82                         Lalala lb = new Lalala (string.Format ("ab{0}", 'c'), 1);
83                         Assert.AreEqual (la.GetHashCode (), lb.GetHashCode (), "#02");
84
85                         a = new Blah (null, 1);
86                         b = new Blah (null, 1);
87                         Assert.AreEqual (la.GetHashCode (), lb.GetHashCode (), "#03");
88
89                         la = new Lalala (null, 1);
90                         lb = new Lalala (null, 1);
91                         Assert.AreEqual (la.GetHashCode (), lb.GetHashCode (), "#04");
92                 }
93         }
94 }
95