X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2Fcorlib%2FTest%2FSystem%2FInt64Test.cs;h=b12395ea0c084875dcd7c42d8b3363561fcf0e60;hb=5ad1099341581dee94f77b32db728918e90fa64f;hp=a377f943df7b2428bda91ce92eed8c2f8f5f5d52;hpb=f11aa9faf50ec2997ea88350885a0d10ec0d815c;p=mono.git diff --git a/mcs/class/corlib/Test/System/Int64Test.cs b/mcs/class/corlib/Test/System/Int64Test.cs index a377f943df7..b12395ea0c0 100644 --- a/mcs/class/corlib/Test/System/Int64Test.cs +++ b/mcs/class/corlib/Test/System/Int64Test.cs @@ -12,8 +12,6 @@ using System; using System.Globalization; using System.Threading; -using AssertType = NUnit.Framework.Assert; - /// /// Tests for System.Int64 /// @@ -21,7 +19,7 @@ namespace MonoTests.System { [TestFixture] -public class Int64Test : Assertion +public class Int64Test { private const Int64 MyInt64_1 = -42; private const Int64 MyInt64_2 = -9223372036854775808; @@ -54,8 +52,6 @@ public class Int64Test : Assertion private string sval1Test5 = " -"+NumberFormatInfo.InvariantInfo.CurrencySymbol+"1,234,567.00 "; private string sval1Test6 = "("+NumberFormatInfo.InvariantInfo.CurrencySymbol+"1,234,567.00)"; private const string sval1Test7 = "-1,234,567.00"; - private const string sval1UserCur1 = "1234/5/67:000 XYZ-"; - private const string sval2UserCur1 = "1234/5/67:000 XYZ"; private const string sval1UserPercent1 = "-%%%1~2~3~4~5~6~7~0~0;0"; private const string sval2UserPercent1 = "%%%1~2~3~4~5~6~7~0~0;0"; private const NumberStyles style1 = NumberStyles.AllowLeadingWhite | NumberStyles.AllowLeadingSign @@ -111,36 +107,40 @@ public class Int64Test : Assertion Thread.CurrentThread.CurrentCulture = old_culture; } + [Test] public void TestMinMax() { - AssertEquals(Int64.MinValue, MyInt64_2); - AssertEquals(Int64.MaxValue, MyInt64_3); + Assert.AreEqual(Int64.MinValue, MyInt64_2); + Assert.AreEqual(Int64.MaxValue, MyInt64_3); } - + + [Test] public void TestCompareTo() { - Assert(MyInt64_3.CompareTo(MyInt64_2) > 0); - Assert(MyInt64_2.CompareTo(MyInt64_2) == 0); - Assert(MyInt64_1.CompareTo((object)(Int64)(-42)) == 0); - Assert(MyInt64_2.CompareTo(MyInt64_3) < 0); + Assert.IsTrue(MyInt64_3.CompareTo(MyInt64_2) > 0); + Assert.IsTrue(MyInt64_2.CompareTo(MyInt64_2) == 0); + Assert.IsTrue(MyInt64_1.CompareTo((object)(Int64)(-42)) == 0); + Assert.IsTrue(MyInt64_2.CompareTo(MyInt64_3) < 0); try { MyInt64_2.CompareTo((object)(Int16)100); - Fail("Should raise a System.ArgumentException"); + Assert.Fail("Should raise a System.ArgumentException"); } catch (Exception e) { - Assert(typeof(ArgumentException) == e.GetType()); + Assert.IsTrue(typeof(ArgumentException) == e.GetType()); } } + [Test] public void TestEquals() { - Assert(MyInt64_1.Equals(MyInt64_1)); - Assert(MyInt64_1.Equals((object)(Int64)(-42))); - Assert(MyInt64_1.Equals((object)(SByte)(-42)) == false); - Assert(MyInt64_1.Equals(MyInt64_2) == false); + Assert.IsTrue(MyInt64_1.Equals(MyInt64_1)); + Assert.IsTrue(MyInt64_1.Equals((object)(Int64)(-42))); + Assert.IsTrue(MyInt64_1.Equals((object)(SByte)(-42)) == false); + Assert.IsTrue(MyInt64_1.Equals(MyInt64_2) == false); } - + + [Test] public void TestGetHashCode() { try { @@ -149,38 +149,41 @@ public class Int64Test : Assertion MyInt64_3.GetHashCode(); } catch { - Fail("GetHashCode should not raise an exception here"); + Assert.Fail("GetHashCode should not raise an exception here"); } } - + + [Test] public void TestRoundTripGeneral() { foreach(long lv in vals) { string s = lv.ToString(Nfi); long lv2 = Int64.Parse(s); - Assert(lv == lv2); + Assert.IsTrue(lv == lv2); long lv3 = Int64.Parse(s, NumberStyles.Integer, Nfi); - Assert(lv == lv3); + Assert.IsTrue(lv == lv3); } } + [Test] public void TestRoundTripHex() { foreach(long lv in vals) { string s = lv.ToString("x", Nfi); long lv2 = Int64.Parse(s, NumberStyles.HexNumber, Nfi); - Assert(lv == lv2); + Assert.IsTrue(lv == lv2); } } + [Test] public void TestParseNull() { try { Int64.Parse(null); - Fail("Should raise System.ArgumentNullException"); + Assert.Fail("Should raise System.ArgumentNullException"); } catch (ArgumentNullException) { @@ -188,17 +191,18 @@ public class Int64Test : Assertion } } + [Test] public void TestParse() { long lv; lv = Int64.Parse(sval1Test1, style1, Nfi); - AssertEquals("Long value should be equal for Test1", val1, lv); + Assert.AreEqual(val1, lv, "Long value should be equal for Test1"); try { lv = Int64.Parse(sval1Test1, Nfi); - Fail("Should raise FormatException 1"); + Assert.Fail("Should raise FormatException 1"); } catch (FormatException) { @@ -206,14 +210,14 @@ public class Int64Test : Assertion } lv = Int64.Parse(sval1Test2, style1, Nfi); - AssertEquals("Value should be the same for Test2 with style1", val1, lv); + Assert.AreEqual(val1, lv, "Value should be the same for Test2 with style1"); lv = Int64.Parse(sval1Test2, Nfi); - AssertEquals("Value should be the same for Test2 without style1", val1, lv); + Assert.AreEqual(val1, lv, "Value should be the same for Test2 without style1"); try { lv = Int64.Parse(sval1Test4, style1, Nfi); - Fail("Should raise FormatException 3"); + Assert.Fail("Should raise FormatException 3"); } catch (FormatException) { @@ -221,175 +225,310 @@ public class Int64Test : Assertion } lv = Int64.Parse(sval1Test5, NumberStyles.Currency, Nfi); - AssertEquals("Value should be the same for Test5 and currency style", val1, lv); + Assert.AreEqual(val1, lv, "Value should be the same for Test5 and currency style"); //test Parse(string s) - Assert(MyInt64_1 == Int64.Parse(MyString1)); - Assert(MyInt64_2 == Int64.Parse(MyString2)); - Assert(MyInt64_3 == Int64.Parse(MyString3)); + Assert.IsTrue(MyInt64_1 == Int64.Parse(MyString1)); + Assert.IsTrue(MyInt64_2 == Int64.Parse(MyString2)); + Assert.IsTrue(MyInt64_3 == Int64.Parse(MyString3)); try { Int64.Parse(null); - Fail("#1:Should raise a System.ArgumentNullException"); + Assert.Fail("#1:Should raise a System.ArgumentNullException"); } catch (Exception e) { - Assert("#2", typeof(ArgumentNullException) == e.GetType()); + Assert.IsTrue(typeof(ArgumentNullException) == e.GetType(), "#2"); } try { Int64.Parse("not-a-number"); - Fail("#3:Should raise a System.FormatException"); + Assert.Fail("#3:Should raise a System.FormatException"); } catch (Exception e) { - Assert("#4", typeof(FormatException) == e.GetType()); + Assert.IsTrue(typeof(FormatException) == e.GetType(), "#4"); } //test Parse(string s, NumberStyles style) try { double OverInt = (double)Int64.MaxValue + 1; Int64.Parse(OverInt.ToString(), NumberStyles.Float); - Fail("#5:Should raise a System.OverflowException"); + Assert.Fail("#5:Should raise a System.OverflowException"); } catch (Exception e) { - Assert("#6", typeof(OverflowException) == e.GetType()); + Assert.IsTrue(typeof(OverflowException) == e.GetType(), "#6"); } try { Int64.Parse("10000000000000000", NumberStyles.HexNumber); - Fail("#7:Should raise a System.OverflowException"); + Assert.Fail("#7:Should raise a System.OverflowException"); } catch (Exception e) { - Assert("#8", typeof(OverflowException) == e.GetType()); + Assert.IsTrue(typeof(OverflowException) == e.GetType(), "#8"); } try { double OverInt = (double)Int64.MaxValue + 1; Int64.Parse(OverInt.ToString(), NumberStyles.Integer); - Fail("#9:Should raise a System.FormatException"); + Assert.Fail("#9:Should raise a System.FormatException"); } catch (Exception e) { - Assert("#10", typeof(FormatException) == e.GetType()); + Assert.IsTrue(typeof(FormatException) == e.GetType(), "#10"); } - AssertEquals("A1", (long)42, Int64.Parse(" "+NumberFormatInfo.CurrentInfo.CurrencySymbol+"42 ", NumberStyles.Currency)); + Assert.AreEqual((long)42, Int64.Parse(" "+NumberFormatInfo.CurrentInfo.CurrencySymbol+"42 ", NumberStyles.Currency), "A1"); try { Int64.Parse(NumberFormatInfo.CurrentInfo.CurrencySymbol+"42", NumberStyles.Integer); - Fail("#11:Should raise a System.FormatException"); + Assert.Fail("#11:Should raise a System.FormatException"); } catch (Exception e) { - Assert("#12", typeof(FormatException) == e.GetType()); + Assert.IsTrue(typeof(FormatException) == e.GetType(), "#12"); } //test Parse(string s, IFormatProvider provider) - Assert("A2", -42 == Int64.Parse(" -42 ", Nfi)); + Assert.IsTrue(-42 == Int64.Parse(" -42 ", Nfi), "A2"); try { Int64.Parse("%42", Nfi); - Fail("#13:Should raise a System.FormatException"); + Assert.Fail("#13:Should raise a System.FormatException"); } catch (Exception e) { - Assert("#14", typeof(FormatException) == e.GetType()); + Assert.IsTrue(typeof(FormatException) == e.GetType(), "#14"); } //test Parse(string s, NumberStyles style, IFormatProvider provider) - Assert("A3", 16 == Int64.Parse(" 10 ", NumberStyles.HexNumber, Nfi)); + Assert.IsTrue(16 == Int64.Parse(" 10 ", NumberStyles.HexNumber, Nfi), "A3"); try { Int64.Parse(NumberFormatInfo.CurrentInfo.CurrencySymbol+"42", NumberStyles.Integer, Nfi); - Fail("#15:Should raise a System.FormatException"); + Assert.Fail("#15:Should raise a System.FormatException"); } catch (Exception e) { - Assert("#16", typeof(FormatException) == e.GetType()); + Assert.IsTrue(typeof(FormatException) == e.GetType(), "#16"); } try { long.Parse ("9223372036854775808"); - AssertType.Fail ("#17:should raise an OverflowException"); + Assert.Fail ("#17:should raise an OverflowException"); } catch (Exception e) { - Assert("#18", typeof(OverflowException) == e.GetType()); + Assert.IsTrue(typeof(OverflowException) == e.GetType(), "#18"); } try { long.Parse ("9223372036854775808", CultureInfo.InvariantCulture); - AssertType.Fail ("#19:should raise an OverflowException"); + Assert.Fail ("#19:should raise an OverflowException"); } catch (Exception e) { - Assert("#20", typeof(OverflowException) == e.GetType()); + Assert.IsTrue(typeof(OverflowException) == e.GetType(), "#20"); } + + try { + Int64.Parse ("5", NumberStyles.Any, CultureInfo.InvariantCulture); + Assert.Fail ("C#42"); + } catch (FormatException) { + } + + // Pass a DateTimeFormatInfo, it is unable to format + // numbers, but we should not crash + + Int64.Parse ("123", new DateTimeFormatInfo ()); + + Assert.AreEqual (734561, Int64.Parse ("734561\0"), "#21"); + Assert.AreEqual (734561, Int64.Parse ("734561\0\0\0 \0"), "#22"); + Assert.AreEqual (734561, Int64.Parse ("734561\0\0\0 "), "#23"); + Assert.AreEqual (734561, Int64.Parse ("734561\0\0\0"), "#24"); + + Assert.AreEqual (0, Int64.Parse ("0+", NumberStyles.Any), "#30"); } + [Test] + public void TestParseExponent () + { + Assert.AreEqual (2, long.Parse ("2E0", NumberStyles.AllowExponent), "A#1"); + Assert.AreEqual (20, long.Parse ("2E1", NumberStyles.AllowExponent), "A#2"); + Assert.AreEqual (200, long.Parse ("2E2", NumberStyles.AllowExponent), "A#3"); + Assert.AreEqual (2000000, long.Parse ("2E6", NumberStyles.AllowExponent), "A#4"); + Assert.AreEqual (200, long.Parse ("2E+2", NumberStyles.AllowExponent), "A#5"); + Assert.AreEqual (2, long.Parse ("2", NumberStyles.AllowExponent), "A#6"); + Assert.AreEqual (21, long.Parse ("2.1E1", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#7"); + Assert.AreEqual (520, long.Parse (".52E3", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#8"); + Assert.AreEqual (32500000, long.Parse ("32.5E6", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#9"); + Assert.AreEqual (890, long.Parse ("8.9000E2", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#10"); + + try { + long.Parse ("2E"); + Assert.Fail ("B#1"); + } catch (FormatException) { + } + + try { + long.Parse ("2E3.0", NumberStyles.AllowExponent); // decimal notation for the exponent + Assert.Fail ("B#2"); + } catch (FormatException) { + } + + try { + long.Parse ("2E 2", NumberStyles.AllowExponent); + Assert.Fail ("B#3"); + } catch (FormatException) { + } + + try { + long.Parse ("2E2 ", NumberStyles.AllowExponent); + Assert.Fail ("B#4"); + } catch (FormatException) { + } + + try { + long.Parse ("2E66", NumberStyles.AllowExponent); // final result overflow + Assert.Fail ("B#5"); + } catch (OverflowException) { + } + + try { + long exponent = (long) Int32.MaxValue + 10; + long.Parse ("2E" + exponent.ToString (), NumberStyles.AllowExponent); + Assert.Fail ("B#6"); + } catch (OverflowException) { + } + + try { + long.Parse ("2E-1", NumberStyles.AllowExponent); // negative exponent + Assert.Fail ("B#7"); + } catch (OverflowException) { + } + + try { + long.Parse ("2 math e1", NumberStyles.AllowExponent); + Assert.Fail ("B#8"); + } catch (FormatException) { + } + + try { + long.Parse ("2.09E1", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent); + Assert.Fail ("B#9"); + } catch (OverflowException) { + } + } + + [Test] + public void TestTryParse() + { + long result; + + Assert.AreEqual (true, long.TryParse (MyString1, out result)); + Assert.AreEqual (MyInt64_1, result); + Assert.AreEqual (true, long.TryParse (MyString2, out result)); + Assert.AreEqual (MyInt64_2, result); + Assert.AreEqual (true, long.TryParse (MyString3, out result)); + Assert.AreEqual (MyInt64_3, result); + + Assert.AreEqual (true, long.TryParse ("1", out result)); + Assert.AreEqual (1, result); + Assert.AreEqual (true, long.TryParse (" 1", out result)); + Assert.AreEqual (1, result); + Assert.AreEqual (true, long.TryParse (" 1", out result)); + Assert.AreEqual (1, result); + Assert.AreEqual (true, long.TryParse ("1 ", out result)); + Assert.AreEqual (1, result); + Assert.AreEqual (true, long.TryParse ("+1", out result)); + Assert.AreEqual (1, result); + Assert.AreEqual (true, long.TryParse ("-1", out result)); + Assert.AreEqual (-1, result); + Assert.AreEqual (true, long.TryParse (" -1", out result)); + Assert.AreEqual (-1, result); + Assert.AreEqual (true, long.TryParse (" -1 ", out result)); + Assert.AreEqual (-1, result); + Assert.AreEqual (true, long.TryParse (" -1 ", out result)); + Assert.AreEqual (-1, result); + + result = 1; + Assert.AreEqual (false, long.TryParse (null, out result)); + Assert.AreEqual (0, result); + + Assert.AreEqual (false, long.TryParse ("not-a-number", out result)); + + double OverInt = (double)long.MaxValue + 1; + Assert.AreEqual (false, long.TryParse (OverInt.ToString (), out result)); + Assert.AreEqual (false, long.TryParse (OverInt.ToString (), NumberStyles.None, CultureInfo.InvariantCulture, out result)); + + Assert.AreEqual (false, long.TryParse ("$42", NumberStyles.Integer, null, out result)); + Assert.AreEqual (false, long.TryParse ("%42", NumberStyles.Integer, Nfi, out result)); + Assert.AreEqual (false, long.TryParse ("$42", NumberStyles.Integer, Nfi, out result)); + Assert.AreEqual (false, long.TryParse (" - 1 ", out result)); + Assert.AreEqual (false, long.TryParse (" - ", out result)); + Assert.AreEqual (true, long.TryParse ("100000000", NumberStyles.HexNumber, Nfi, out result)); + Assert.AreEqual (true, long.TryParse ("10000000000", out result)); + Assert.AreEqual (true, long.TryParse ("-10000000000", out result)); + Assert.AreEqual (true, long.TryParse ("7fffffff", NumberStyles.HexNumber, Nfi, out result)); + Assert.AreEqual (int.MaxValue, result); + Assert.AreEqual (true, long.TryParse ("80000000", NumberStyles.HexNumber, Nfi, out result)); + Assert.AreEqual (2147483648, result); + Assert.AreEqual (true, long.TryParse ("ffffffff", NumberStyles.HexNumber, Nfi, out result)); + Assert.AreEqual (uint.MaxValue, result); + Assert.AreEqual (true, long.TryParse ("100000000", NumberStyles.HexNumber, Nfi, out result)); + Assert.IsFalse (long.TryParse ("-", NumberStyles.AllowLeadingSign, Nfi, out result)); + Assert.IsFalse (long.TryParse (Nfi.CurrencySymbol + "-", NumberStyles.AllowLeadingSign | NumberStyles.AllowCurrencySymbol, Nfi, out result)); + } + + [Test] public void TestToString() { string s; s = val1.ToString("c", Nfi); - Assert("val1 does not become sval1Test6", s.Equals(sval1Test6)); + Assert.IsTrue(s.Equals(sval1Test6), "val1 does not become sval1Test6"); s = val1.ToString("n", Nfi); - AssertEquals("val1 does not become sval1Test7", sval1Test7, s); + Assert.AreEqual(sval1Test7, s, "val1 does not become sval1Test7"); //test ToString() - AssertEquals("MyInt64_1.ToString()", MyString1, MyInt64_1.ToString()); - AssertEquals("MyInt64_2.ToString()", MyString2, MyInt64_2.ToString()); - AssertEquals("MyInt64_3.ToString()", MyString3, MyInt64_3.ToString()); + Assert.AreEqual(MyString1, MyInt64_1.ToString(), "MyInt64_1.ToString()"); + Assert.AreEqual(MyString2, MyInt64_2.ToString(), "MyInt64_2.ToString()"); + Assert.AreEqual(MyString3, MyInt64_3.ToString(), "MyInt64_3.ToString()"); //test ToString(string format) for (int i=0; i < Formats1.Length; i++) { - AssertEquals("MyInt64_2.ToString(Formats1["+i+"])", Results1[i], MyInt64_2.ToString(Formats1[i])); - AssertEquals("MyInt64_3.ToString(Formats2["+i+"])", Results2[i], MyInt64_3.ToString(Formats2[i])); + Assert.AreEqual(Results1[i], MyInt64_2.ToString(Formats1[i]), "MyInt64_2.ToString(Formats1["+i+"])"); + Assert.AreEqual(Results2[i], MyInt64_3.ToString(Formats2[i]), "MyInt64_3.ToString(Formats2["+i+"])"); } //test ToString(string format, IFormatProvider provider); for (int i=0; i < Formats1.Length; i++) { - AssertEquals("MyInt64_2.ToString(Formats1["+i+"], Nfi)", ResultsNfi1[i], MyInt64_2.ToString(Formats1[i], Nfi)); - AssertEquals("MyInt64_3.ToString(Formats2["+i+"], Nfi)", ResultsNfi2[i], MyInt64_3.ToString(Formats2[i], Nfi)); + Assert.AreEqual(ResultsNfi1[i], MyInt64_2.ToString(Formats1[i], Nfi), "MyInt64_2.ToString(Formats1["+i+"], Nfi)"); + Assert.AreEqual(ResultsNfi2[i], MyInt64_3.ToString(Formats2[i], Nfi), "MyInt64_3.ToString(Formats2["+i+"], Nfi)"); } try { MyInt64_1.ToString("z"); - Fail("Should raise a System.FormatException"); + Assert.Fail("Should raise a System.FormatException"); } catch (Exception e) { - AssertEquals("Exception is wrong type", typeof(FormatException), e.GetType()); + Assert.AreEqual(typeof(FormatException), e.GetType(), "Exception is wrong type"); } } - public void TestUserCurrency() - { - string s= ""; - long v; - int iTest = 1; - try { - s = val1.ToString("c", NfiUser); - iTest++; - AssertEquals("Currency value type 1 is not what we want to try to parse", sval1UserCur1, s); - iTest++; - v = Int64.Parse(s, NumberStyles.Currency, NfiUser); - iTest++; - Assert(v == val1); - } catch (Exception e) { - Fail ("1 Unexpected exception at iTest = " + iTest + ", s = " + s + ":e = " + e); - } - - iTest = 1; - try { - s = val2.ToString("c", NfiUser); - iTest++; - AssertEquals("Currency value type 2 is not what we want to try to parse", sval2UserCur1, s); - iTest++; - v = Int64.Parse(s, NumberStyles.Currency, NfiUser); - iTest++; - Assert(v == val2); - } catch (Exception e) { - Fail ("2 Unexpected exception at iTest = " + iTest + ":e = " + e); + [Test] + public void TestUserCurrency () + { + string s = ""; + long v; + s = val1.ToString ("c", NfiUser); + Assert.AreEqual ("1234/5/67:000 XYZ-", s, "Currency value type 1 is not what we want to try to parse"); + v = Int64.Parse ("1234/5/67:000 XYZ-", NumberStyles.Currency, NfiUser); + Assert.AreEqual (val1, v); + + s = val2.ToString ("c", NfiUser); + Assert.AreEqual ("1234/5/67:000 XYZ", s, "Currency value type 2 is not what we want to try to parse"); + v = Int64.Parse (s, NumberStyles.Currency, NfiUser); + Assert.AreEqual (val2, v); } - } + [Test] public void TestUserPercent() { string s; s = val1.ToString("p", NfiUser); - Assert(s.Equals(sval1UserPercent1)); + Assert.IsTrue(s.Equals(sval1UserPercent1)); s = val2.ToString("p", NfiUser); - Assert(s.Equals(sval2UserPercent1)); + Assert.IsTrue(s.Equals(sval2UserPercent1)); } [Test] public void Parse_MaxValue () { - AssertEquals ("9223372036854775807", Int64.MaxValue, Int64.Parse ("9223372036854775807")); + Assert.AreEqual (Int64.MaxValue, Int64.Parse ("9223372036854775807"), "9223372036854775807"); } [Test] public void Parse_MinValue () { - AssertEquals ("-9223372036854775808,10", Int64.MinValue, Int64.Parse ("-9223372036854775808")); + Assert.AreEqual (Int64.MinValue, Int64.Parse ("-9223372036854775808"), "-9223372036854775808,10"); } [Test] @@ -426,14 +565,14 @@ public class Int64Test : Assertion Int64 i = 254; // everything defaults to "G" string def = i.ToString ("G"); - AssertEquals ("ToString()", def, i.ToString ()); - AssertEquals ("ToString((IFormatProvider)null)", def, i.ToString ((IFormatProvider)null)); - AssertEquals ("ToString((string)null)", def, i.ToString ((string)null)); - AssertEquals ("ToString(empty)", def, i.ToString (String.Empty)); - AssertEquals ("ToString(null,null)", def, i.ToString (null, null)); - AssertEquals ("ToString(empty,null)", def, i.ToString (String.Empty, null)); - - AssertEquals ("ToString(G)", "254", def); + Assert.AreEqual (def, i.ToString (), "ToString()"); + Assert.AreEqual (def, i.ToString ((IFormatProvider)null), "ToString((IFormatProvider)null)"); + Assert.AreEqual (def, i.ToString ((string)null), "ToString((string)null)"); + Assert.AreEqual (def, i.ToString (String.Empty), "ToString(empty)"); + Assert.AreEqual (def, i.ToString (null, null), "ToString(null,null)"); + Assert.AreEqual (def, i.ToString (String.Empty, null), "ToString(empty,null)"); + + Assert.AreEqual ("254", def, "ToString(G)"); } } }