[corlib] Make primitive types smaller than int compare result compatible
[mono.git] / mcs / class / corlib / Test / System / Int16Test.cs
index 05f535499d69d7e9a9c5ce0a9e0c2142002f3e91..93317046963230c0fed81c4b0bbb9fd69e41949a 100644 (file)
@@ -71,16 +71,14 @@ public class Int16Test
        [Test]  
        public void TestCompareTo()
        {
-               Assert.IsTrue(MyInt16_3.CompareTo(MyInt16_2) > 0);
-               Assert.IsTrue(MyInt16_2.CompareTo(MyInt16_2) == 0);
-               Assert.IsTrue(MyInt16_1.CompareTo((Int16)(-42)) == 0);
-               Assert.IsTrue(MyInt16_2.CompareTo(MyInt16_3) < 0);
+               Assert.AreEqual(65535, MyInt16_3.CompareTo(MyInt16_2), "#1");
+               Assert.AreEqual(0, MyInt16_2.CompareTo(MyInt16_2), "#2");
+               Assert.AreEqual(0, MyInt16_1.CompareTo((Int16)(-42)), "#3");
+               Assert.AreEqual(-65535, MyInt16_2.CompareTo(MyInt16_3), "#4");
                try {
                        MyInt16_2.CompareTo((object)100);
                        Assert.Fail ("Should raise a System.ArgumentException");
-               }
-               catch (Exception e) {
-                       Assert.IsTrue(typeof(ArgumentException) == e.GetType());
+               } catch (ArgumentException e) {
                }
        }
 
@@ -178,6 +176,7 @@ public class Int16Test
                Assert.AreEqual (20, Int16.Parse ("2E1", NumberStyles.AllowExponent), "A#2");
                Assert.AreEqual (200, Int16.Parse ("2E2", NumberStyles.AllowExponent), "A#3");
                Assert.AreEqual (200, Int16.Parse ("2E+2", NumberStyles.AllowExponent), "A#4");
+               Assert.AreEqual (2, Int16.Parse ("2", NumberStyles.AllowExponent), "A#5");
 
                try {
                        Int16.Parse ("2E");
@@ -221,6 +220,12 @@ public class Int16Test
                        Assert.Fail ("B#7");
                } catch (OverflowException) {
                }
+               
+               try {
+                       Int16.Parse ("2 math e1", NumberStyles.AllowExponent);
+                       Assert.Fail ("B#8");
+               } catch (FormatException) {
+               }
        }
 
        [Test]
@@ -276,6 +281,12 @@ public class Int16Test
 
                Assert.AreEqual ("254", def, "ToString(G)");
        }
+
+       [Test]
+       public void Bug3677 ()
+       {
+               Assert.AreEqual (-7197, short.Parse("E3E3", NumberStyles.HexNumber), "HexNumber");
+       }
 }
 
 }