Merge pull request #1304 from slluis/mac-proxy-autoconfig
[mono.git] / mcs / class / corlib / Test / System / SByteTest.cs
index 07e1e9f514919cce82dbfde5b176f82fc47895e2..c8d40396c299129c83d1754b1d718887b23b3b5c 100644 (file)
@@ -24,12 +24,15 @@ public class SByteTest
        private const string MyString3 = "127";
        private string[] Formats1 = {"c", "d", "e", "f", "g", "n", "p", "x" };
        private string[] Formats2 = {"c5", "d5", "e5", "f5", "g5", "n5", "p5", "x5" };
+#if false
+       // These are not currently being tested against, due to the locale-specific nature of the test, we need a different way of doing this
        private string[] Results1 = {"("+NumberFormatInfo.CurrentInfo.CurrencySymbol+"128.00)",
                                        "-128", "-1.280000e+002", "-128.00",
                                        "-128", "-128.00", "-12,800.00 %", "80"};
        private string[] Results2 = {NumberFormatInfo.CurrentInfo.CurrencySymbol+"127.00000",
                                        "00127", "1.27000e+002", "127.00000",
                                        "127", "127.00000", "12,700.00000 %", "0007f"};
+#endif
        private string[] ResultsNfi1 = {"("+NumberFormatInfo.InvariantInfo.CurrencySymbol+"128.00)", 
                                        "-128", "-1.280000e+002", "-128.00",
                                        "-128", "-128.00", "-12,800.00 %", "80"};
@@ -48,16 +51,14 @@ public class SByteTest
        [Test]
        public void TestCompareTo()
        {
-               Assert.IsTrue(MySByte3.CompareTo(MySByte2) > 0);
-               Assert.IsTrue(MySByte2.CompareTo(MySByte2) == 0);
-               Assert.IsTrue(MySByte1.CompareTo((SByte)(-42)) == 0);
-               Assert.IsTrue(MySByte2.CompareTo(MySByte3) < 0);
+               Assert.AreEqual(255, MySByte3.CompareTo(MySByte2), "#1");
+               Assert.AreEqual(0, MySByte2.CompareTo(MySByte2), "#2");
+               Assert.AreEqual(0, MySByte1.CompareTo((SByte)(-42)), "#3");
+               Assert.AreEqual(-255, MySByte2.CompareTo(MySByte3), "#4");
                try {
                        MySByte2.CompareTo((object)(int)100);
                        Assert.Fail("Should raise a System.ArgumentException");
-               }
-               catch (Exception e) {
-                       Assert.IsTrue(typeof(ArgumentException) == e.GetType());
+               } catch (ArgumentException e) {
                }
        }
 
@@ -163,14 +164,17 @@ public class SByteTest
                Assert.IsTrue(String.Compare(MyString2, MySByte2.ToString()) == 0, "MyString2, MySByte2.ToString()");
                Assert.IsTrue(String.Compare(MyString3, MySByte3.ToString()) == 0, "MyString3, MySByte3.ToString()");
                //test ToString(string format)
+
+#if false
                /*
-               TODO: These tests depend on the culture of the system running the test.
-                       So, this needs to be tested in a different way.
+                * TODO: These tests depend on the culture of the system running the test.
+                * So, this needs to be tested in a different way.
+                /
                for (int i=0; i < Formats1.Length; i++) {
                        Assert.IsTrue("i="+i+", Results1[i]="+Results1[i]+", MySByte2.ToString(Formats1[i])="+MySByte2.ToString(Formats1[i]), String.Compare(Results1[i], MySByte2.ToString(Formats1[i])) == 0);
                        Assert.IsTrue(String.Compare(Results2[i], MySByte3.ToString(Formats2[i])) == 0, "Results2[i], MySByte3.ToString(Formats2[i])");
                }
-               */
+#endif
                //test ToString(string format, IFormatProvider provider);
                for (int i=0; i < Formats1.Length; i++) {
                        Assert.IsTrue(String.Compare(ResultsNfi1[i], MySByte2.ToString(Formats1[i], Nfi)) == 0, "i="+i+", ResultsNfi1[i]="+ResultsNfi1[i]+", MySByte2.ToString(Formats1[i]="+Formats1[i]+"): Expected "+ResultsNfi1[i]+" but got "+MySByte2.ToString(Formats1[i], Nfi));
@@ -200,6 +204,12 @@ public class SByteTest
 
                Assert.AreEqual ("100", def, "ToString(G)");
        }
+               
+       [Test]
+       public void Bug3677 ()
+       {
+               Assert.AreEqual (-29, sbyte.Parse("E3", NumberStyles.HexNumber), "HexNumber");
+       }
 }
 
 }