2002/03/18 Nick Drochak <ndrochak@gol.com>
authorNick Drochak <nickd@mono-cvs.ximian.com>
Mon, 18 Mar 2002 05:30:10 +0000 (05:30 -0000)
committerNick Drochak <nickd@mono-cvs.ximian.com>
Mon, 18 Mar 2002 05:30:10 +0000 (05:30 -0000)
* ByteTest.cs:
* Int64Test.cs:
* SByteTest.cs: Do not hard code the "$" as the currency symbol to
use for Parse tests. This isn not really the fix we need. These
number formats vary wildly depending on the culture the system
runs with.  We need a much better strategy here for testing this.
* Int32Test.cs: Use #if NOTYET-#endif to disable a test.  This removes
an annoying compile warning.

svn path=/trunk/mcs/; revision=3181

mcs/class/corlib/Test/System/ByteTest.cs
mcs/class/corlib/Test/System/ChangeLog
mcs/class/corlib/Test/System/Int32Test.cs
mcs/class/corlib/Test/System/Int64Test.cs
mcs/class/corlib/Test/System/SByteTest.cs

index f825f25910b8e2b670202adc53f1db6d5cfdc31c..70f2c6f151d66fb67ac1413e00107cb76530cea2 100644 (file)
@@ -122,13 +122,15 @@ public class ByteTest : TestCase
                }
 
                //test Parse(string s, NumberStyles style)
-               Assert(" $42 ", 42 == Byte.Parse(" $42 ", NumberStyles.Currency));
+               AssertEquals(" "+NumberFormatInfo.CurrentInfo.CurrencySymbol+"42 ",
+                               (byte)42, Byte.Parse(" "+NumberFormatInfo.CurrentInfo.CurrencySymbol+"42 ",
+                                               NumberStyles.Currency));
                try {
-                       Byte.Parse("$42", NumberStyles.Integer);
+                       Byte.Parse(NumberFormatInfo.CurrentInfo.CurrencySymbol+"42", NumberStyles.Integer);
                        Fail("Should raise a System.FormatException");
                }
                catch (Exception e) {
-                       Assert("$42 and NumberStyles.Integer", typeof(FormatException) == e.GetType());
+                       Assert(NumberFormatInfo.CurrentInfo.CurrencySymbol+"42 and NumberStyles.Integer", typeof(FormatException) == e.GetType());
                }
                //test Parse(string s, IFormatProvider provider)
                Assert(" 42 and Nfi", 42 == Byte.Parse(" 42 ", Nfi));
@@ -142,11 +144,11 @@ public class ByteTest : TestCase
                //test Parse(string s, NumberStyles style, IFormatProvider provider)
                Assert("NumberStyles.HexNumber", 16 == Byte.Parse(" 10 ", NumberStyles.HexNumber, Nfi));
                try {
-                       Byte.Parse("$42", NumberStyles.Integer, Nfi);
+                       Byte.Parse(NumberFormatInfo.CurrentInfo.CurrencySymbol+"42", NumberStyles.Integer, Nfi);
                        Fail("Should raise a System.FormatException");
                }
                catch (Exception e) {
-                       Assert("$42, NumberStyles.Integer, Nfi", typeof(FormatException) == e.GetType());
+                       Assert(NumberFormatInfo.CurrentInfo.CurrencySymbol+"42, NumberStyles.Integer, Nfi", typeof(FormatException) == e.GetType());
                }
        }
        
index 725c0a3eb46acf079ac9ae662890f1c73c935648..c1b1c3a1185a637f2744987c1382d1631d508047 100644 (file)
@@ -1,3 +1,14 @@
+2002/03/18  Nick Drochak <ndrochak@gol.com>
+
+       * ByteTest.cs:
+       * Int64Test.cs:
+       * SByteTest.cs: Do not hard code the "$" as the currency symbol to
+       use for Parse tests. This isn not really the fix we need. These
+       number formats vary wildly depending on the culture the system
+       runs with.  We need a much better strategy here for testing this.
+       * Int32Test.cs: Use #if NOTYET-#endif to disable a test.  This removes
+       an annoying compile warning.
+
 2002-03-18  Nick Drochak  <ndrochak@gol.com>
 
        * DoubleTest.cs:
index 9686254cab6b65d686843e58874cc97212bc54ef..46921ade7c13028e5473169cf33c26579ad83c88 100644 (file)
@@ -224,14 +224,14 @@ public class Int32Test : TestCase
        public void TestCustomToString()
        {
                // FIXME: Not yet implemented.
-               return;
-
+#if NOTYET
                // culture sensitive?
 
                int i = 123;
 
                AssertEquals ("Custom format string 00000", "00123", i.ToString ("00000"));
                AssertEquals ("Custom format string ####", "123", i.ToString ("####"));
+#endif
        }
 }
 
index 33df6c9b708a3df8fbac99b9de7db0addd7e2d07..134f9daf0e02e20eda87ce631f3f962ffc79536a 100644 (file)
@@ -27,9 +27,9 @@ public class Int64Test : TestCase
        private const string MyString3 = "9223372036854775807";
        private string[] Formats1 = {"c", "d", "e", "f", "g", "n", "p", "x" };
        private string[] Formats2 = {"c5", "d5", "e5", "f5", "g5", "n5", "p5", "x5" };
-       private string[] Results1 = {"($9,223,372,036,854,775,808.00)", "-9223372036854775808", "-9.223372e+018", "-9223372036854775808.00",
+       private string[] Results1 = {"("+NumberFormatInfo.CurrentInfo.CurrencySymbol+"9,223,372,036,854,775,808.00)", "-9223372036854775808", "-9.223372e+018", "-9223372036854775808.00",
                                          "-9223372036854775808", "-9,223,372,036,854,775,808.00", "-922,337,203,685,477,580,800.00 %", "8000000000000000"};
-       private string[] Results2 = {"$9,223,372,036,854,775,807.00000", "9223372036854775807", "9.22337e+018", "9223372036854775807.00000",
+       private string[] Results2 = {NumberFormatInfo.CurrentInfo.CurrencySymbol+"9,223,372,036,854,775,807.00000", "9223372036854775807", "9.22337e+018", "9223372036854775807.00000",
                                          "9.2234e+18", "9,223,372,036,854,775,807.00000", "922,337,203,685,477,580,700.00000 %", "7fffffffffffffff"};
        private string[] ResultsNfi1 = {"("+NumberFormatInfo.InvariantInfo.CurrencySymbol+"9,223,372,036,854,775,808.00)", "-9223372036854775808", "-9.223372e+018", "-9223372036854775808.00",
                                          "-9223372036854775808", "-9,223,372,036,854,775,808.00", "-922,337,203,685,477,580,800.00 %", "8000000000000000"};
@@ -238,9 +238,9 @@ public class Int64Test : TestCase
        catch (Exception e) {
                Assert(typeof(FormatException) == e.GetType());
        }
-       Assert(42 == Int64.Parse(" $42 ", NumberStyles.Currency));
+       AssertEquals("A1", (long)42, Int64.Parse(" "+NumberFormatInfo.CurrentInfo.CurrencySymbol+"42 ", NumberStyles.Currency));
        try {
-               Int64.Parse("$42", NumberStyles.Integer);
+               Int64.Parse(NumberFormatInfo.CurrentInfo.CurrencySymbol+"42", NumberStyles.Integer);
                Fail("Should raise a System.FormatException");
        }
        catch (Exception e) {
@@ -258,7 +258,7 @@ public class Int64Test : TestCase
        //test Parse(string s, NumberStyles style, IFormatProvider provider)
        Assert(16 == Int64.Parse(" 10 ", NumberStyles.HexNumber, Nfi));
        try {
-               Int64.Parse("$42", NumberStyles.Integer, Nfi);
+               Int64.Parse(NumberFormatInfo.CurrentInfo.CurrencySymbol+"42", NumberStyles.Integer, Nfi);
                Fail("Should raise a System.FormatException");
        }
        catch (Exception e) {
index 611d3e4b8122946a656a01196907c34c512fdc87..0005eb55c63d11d1a5300c29c5b588090364a136 100644 (file)
@@ -22,7 +22,7 @@ public class SByteTest : TestCase
        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" };
-       private string[] Results1 = {"("+NumberFormatInfo.CurrentInfo.CurrencySymbol+"$128.00)",
+       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",
@@ -119,9 +119,9 @@ public class SByteTest : TestCase
                        Assert(typeof(OverflowException) == e.GetType());
                }
                //test Parse(string s, NumberStyles style)
-               Assert(42 == SByte.Parse(" $42 ", NumberStyles.Currency));
+               AssertEquals("A1", (sbyte)42, SByte.Parse(" "+NumberFormatInfo.CurrentInfo.CurrencySymbol+"42 ", NumberStyles.Currency));
                try {
-                       SByte.Parse("$42", NumberStyles.Integer);
+                       SByte.Parse(NumberFormatInfo.CurrentInfo.CurrencySymbol+"42", NumberStyles.Integer);
                        Fail("Should raise a System.FormatException");
                }
                catch (Exception e) {
@@ -139,7 +139,7 @@ public class SByteTest : TestCase
                //test Parse(string s, NumberStyles style, IFormatProvider provider)
                Assert(16 == SByte.Parse(" 10 ", NumberStyles.HexNumber, Nfi));
                try {
-                       SByte.Parse("$42", NumberStyles.Integer, Nfi);
+                       SByte.Parse(NumberFormatInfo.CurrentInfo.CurrencySymbol+"42", NumberStyles.Integer, Nfi);
                        Fail("Should raise a System.FormatException");
                }
                catch (Exception e) {