}
//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));
//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());
}
}
+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:
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
}
}
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"};
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) {
//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) {
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",
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) {
//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) {