}
catch (Exception e) {
AssertEquals("#A33", typeof(ArgumentNullException), e.GetType());
- }
+ }
+
+ try {
+ /* should fail to convert string to any enumeration type. */
+ Convert.ChangeType("random string", typeof(DayOfWeek));
+ Fail();
+ }
+ catch (Exception e) {
+ AssertEquals("#A34", typeof(InvalidCastException), e.GetType());
+ }
+
}
public void TestGetTypeCode() {
AssertEquals("#F07", '@', Convert.ToChar("@"));
AssertEquals("#F08", 'K', Convert.ToChar((ushort)75));
AssertEquals("#F09", '=', Convert.ToChar((uint)61));
- // AssertEquals("#F10", 'È', Convert.ToChar((ulong)200));
+ // AssertEquals("#F10", 'E', Convert.ToChar((ulong)200));
AssertEquals("#F11", '{', Convert.ToChar((object)trySByte, ci));
AssertEquals("#F12", 'o', Convert.ToChar(tryStr.Substring(1,1), ci));
AssertEquals("#H09", (decimal)trySByte, Convert.ToDecimal(trySByte));
AssertEquals("#H10", (decimal)tryFloat, Convert.ToDecimal(tryFloat));
string sep = NumberFormatInfo.CurrentInfo.NumberDecimalSeparator;
- AssertEquals("#H11", (decimal)23456.432, Convert.ToDecimal("23456" + sep + "432"));
+// AssertEquals("#H11", (decimal)23456.432, Convert.ToDecimal("23456" + sep + "432"));
+// Note: changed because the number were the same but with a different base
+// and this isn't a Convert bug (but a Decimal bug). See #60227 for more details.
+// http://bugzilla.ximian.com/show_bug.cgi?id=60227
+ Assert ("#H11", Decimal.Equals (23456.432m, Convert.ToDecimal ("23456" + sep + "432")));
AssertEquals("#H12", (decimal)tryUI16, Convert.ToDecimal(tryUI16));
AssertEquals("#H13", (decimal)tryUI32, Convert.ToDecimal(tryUI32));
AssertEquals("#H14", (decimal)tryUI64, Convert.ToDecimal(tryUI64));
AssertEquals ("0XfF", 255, Convert.ToByte ("0XfF", 16));
AssertEquals ("0XFf", 255, Convert.ToByte ("0XFf", 16));
AssertEquals ("0XFF", 255, Convert.ToByte ("0XFF", 16));
+
+ AssertEquals ("0x0", Byte.MinValue, Convert.ToByte ("0x0", 16));
+ }
+
+ [Test]
+ [ExpectedException (typeof (FormatException))]
+ public void ToByte_BadHexPrefix ()
+ {
+ Convert.ToByte ("0x", 16);
}
[Test]
Convert.ToByte ("-1");
}
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ToByte_NegativeStringNonBase10 ()
+ {
+ Convert.ToByte ("-0", 16);
+ }
+
+ [Test]
+ [ExpectedException (typeof (OverflowException))]
+ public void ToByte_NegativeString_Base10 ()
+ {
+ Convert.ToByte ("-0", 10);
+ }
+
[Test]
public void ToByte_NegativeZeroString ()
{
- // legal
Convert.ToByte ("-0");
+ Convert.ToByte ("-0", null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (OverflowException))]
+ public void ToUInt16_NegativeString ()
+ {
+ Convert.ToUInt16 ("-1");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ToUInt16_NegativeStringNonBase10 ()
+ {
+ Convert.ToUInt16 ("-0", 16);
+ }
+
+ [Test]
+ [ExpectedException (typeof (OverflowException))]
+ public void ToUInt16_NegativeString_Base10 ()
+ {
+ Convert.ToUInt16 ("-0", 10);
+ }
+
+ [Test]
+ public void ToUInt16_NegativeZeroString ()
+ {
+ Convert.ToUInt16 ("-0");
+ Convert.ToUInt16 ("-0", null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (OverflowException))]
+ public void ToUInt32_NegativeString ()
+ {
+ Convert.ToUInt32 ("-1");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ToUInt32_NegativeStringNonBase10 ()
+ {
+ Convert.ToUInt32 ("-0", 16);
+ }
+
+ [Test]
+ [ExpectedException (typeof (OverflowException))]
+ public void ToUInt32_NegativeString_Base10 ()
+ {
+ Convert.ToUInt32 ("-0", 10);
+ }
+
+ [Test]
+ public void ToUInt32_NegativeZeroString ()
+ {
+ Convert.ToUInt32 ("-0");
+ Convert.ToUInt32 ("-0", null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (OverflowException))]
+ public void ToUInt64_NegativeString ()
+ {
+ Convert.ToUInt64 ("-1");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ToUInt64_NegativeStringNonBase10 ()
+ {
+ Convert.ToUInt64 ("-0", 16);
+ }
+
+ [Test]
+ [ExpectedException (typeof (OverflowException))]
+ public void ToUInt64_NegativeString_Base10 ()
+ {
+ Convert.ToUInt64 ("-0", 10);
+ }
+
+ [Test]
+ public void ToUInt64_NegativeZeroString ()
+ {
+ Convert.ToUInt64 ("-0");
+ Convert.ToUInt64 ("-0", null);
+ }
+
+ // min/max unsigned
+
+ [Test]
+ public void ToByte_MaxValue ()
+ {
+ AssertEquals ("ff,16", Byte.MaxValue, Convert.ToByte ("ff", 16));
+ AssertEquals ("255,10", Byte.MaxValue, Convert.ToByte ("255", 10));
+ AssertEquals ("377,8", Byte.MaxValue, Convert.ToByte ("377", 8));
+ AssertEquals ("11111111,2", Byte.MaxValue, Convert.ToByte ("11111111", 2));
+ }
+
+ [Test]
+ public void ToByte_MinValue ()
+ {
+ AssertEquals ("0,16", Byte.MinValue, Convert.ToByte ("0", 16));
+ AssertEquals ("0,10", Byte.MinValue, Convert.ToByte ("0", 10));
+ AssertEquals ("0,8", Byte.MinValue, Convert.ToByte ("0", 8));
+ AssertEquals ("0,2", Byte.MinValue, Convert.ToByte ("0", 2));
+ }
+
+ [Test]
+ public void ToUInt16_MaxValue ()
+ {
+ AssertEquals ("ffff,16", UInt16.MaxValue, Convert.ToUInt16 ("ffff", 16));
+ AssertEquals ("65535,10", UInt16.MaxValue, Convert.ToUInt16 ("65535", 10));
+ AssertEquals ("177777,8", UInt16.MaxValue, Convert.ToUInt16 ("177777", 8));
+ AssertEquals ("1111111111111111,2", UInt16.MaxValue, Convert.ToUInt16 ("1111111111111111", 2));
+ }
+
+ [Test]
+ public void ToUInt16_MinValue ()
+ {
+ AssertEquals ("0,16", UInt16.MinValue, Convert.ToUInt16 ("0", 16));
+ AssertEquals ("0,10", UInt16.MinValue, Convert.ToUInt16 ("0", 10));
+ AssertEquals ("0,8", UInt16.MinValue, Convert.ToUInt16 ("0", 8));
+ AssertEquals ("0,2", UInt16.MinValue, Convert.ToUInt16 ("0", 2));
+ }
+
+ [Test]
+ public void ToUInt32_MaxValue ()
+ {
+ AssertEquals ("ffffffff,16", UInt32.MaxValue, Convert.ToUInt32 ("ffffffff", 16));
+ AssertEquals ("4294967295,10", UInt32.MaxValue, Convert.ToUInt32 ("4294967295", 10));
+ AssertEquals ("37777777777,8", UInt32.MaxValue, Convert.ToUInt32 ("37777777777", 8));
+ AssertEquals ("11111111111111111111111111111111,2", UInt32.MaxValue, Convert.ToUInt32 ("11111111111111111111111111111111", 2));
+ }
+
+ [Test]
+ public void ToUInt32_MinValue ()
+ {
+ AssertEquals ("0,16", UInt32.MinValue, Convert.ToUInt32 ("0", 16));
+ AssertEquals ("0,10", UInt32.MinValue, Convert.ToUInt32 ("0", 10));
+ AssertEquals ("0,8", UInt32.MinValue, Convert.ToUInt32 ("0", 8));
+ AssertEquals ("0,2", UInt32.MinValue, Convert.ToUInt32 ("0", 2));
+ }
+
+ [Test]
+ public void ToUInt64_MaxValue ()
+ {
+ AssertEquals ("ffffffffffffffff,16", UInt64.MaxValue, Convert.ToUInt64 ("ffffffffffffffff", 16));
+ AssertEquals ("18446744073709551615,10", UInt64.MaxValue, Convert.ToUInt64 ("18446744073709551615", 10));
+ AssertEquals ("1777777777777777777777,8", UInt64.MaxValue, Convert.ToUInt64 ("1777777777777777777777", 8));
+ AssertEquals ("1111111111111111111111111111111111111111111111111111111111111111,2", UInt64.MaxValue, Convert.ToUInt64 ("1111111111111111111111111111111111111111111111111111111111111111", 2));
+ }
+
+ [Test]
+ public void ToUInt64_MinValue ()
+ {
+ AssertEquals ("0,16", UInt64.MinValue, Convert.ToUInt64 ("0", 16));
+ AssertEquals ("0,10", UInt64.MinValue, Convert.ToUInt64 ("0", 10));
+ AssertEquals ("0,8", UInt64.MinValue, Convert.ToUInt64 ("0", 8));
+ AssertEquals ("0,2", UInt64.MinValue, Convert.ToUInt64 ("0", 2));
+ }
+
+ // min/max signed
+
+ [Test]
+ public void ToSByte_MaxValue ()
+ {
+ AssertEquals ("7F,16", SByte.MaxValue, Convert.ToSByte ("7f", 16));
+ AssertEquals ("127,10", SByte.MaxValue, Convert.ToSByte ("127", 10));
+ AssertEquals ("177,8", SByte.MaxValue, Convert.ToSByte ("177", 8));
+ AssertEquals ("1111111,2", SByte.MaxValue, Convert.ToSByte ("1111111", 2));
+ }
+
+ [Test]
+ public void ToSByte_MinValue ()
+ {
+ AssertEquals ("80,16", SByte.MinValue, Convert.ToSByte ("80", 16));
+ AssertEquals ("-128,10", SByte.MinValue, Convert.ToSByte ("-128", 10));
+ AssertEquals ("200,8", SByte.MinValue, Convert.ToSByte ("200", 8));
+ AssertEquals ("10000000,2", SByte.MinValue, Convert.ToSByte ("10000000", 2));
+ }
+
+ [Test]
+ public void ToInt16_MaxValue ()
+ {
+ AssertEquals ("7FFF,16", Int16.MaxValue, Convert.ToInt16 ("7fff", 16));
+ AssertEquals ("32767,10", Int16.MaxValue, Convert.ToInt16 ("32767", 10));
+ AssertEquals ("77777,8", Int16.MaxValue, Convert.ToInt16 ("77777", 8));
+ AssertEquals ("111111111111111,2", Int16.MaxValue, Convert.ToInt16 ("111111111111111", 2));
+ }
+
+ [Test]
+ public void ToInt16_MinValue ()
+ {
+ AssertEquals ("8000,16", Int16.MinValue, Convert.ToInt16 ("8000", 16));
+ AssertEquals ("-32768,10", Int16.MinValue, Convert.ToInt16 ("-32768", 10));
+ AssertEquals ("100000,8", Int16.MinValue, Convert.ToInt16 ("100000", 8));
+ AssertEquals ("1000000000000000,2", Int16.MinValue, Convert.ToInt16 ("1000000000000000", 2));
+ }
+
+ [Test]
+ public void ToInt32_MaxValue ()
+ {
+ AssertEquals ("7fffffff,16", Int32.MaxValue, Convert.ToInt32 ("7fffffff", 16));
+ AssertEquals ("2147483647,10", Int32.MaxValue, Convert.ToInt32 ("2147483647", 10));
+ AssertEquals ("17777777777,8", Int32.MaxValue, Convert.ToInt32 ("17777777777", 8));
+ AssertEquals ("1111111111111111111111111111111,2", Int32.MaxValue, Convert.ToInt32 ("1111111111111111111111111111111", 2));
+ }
+
+ [Test]
+ public void ToInt32_MinValue ()
+ {
+ AssertEquals ("80000000,16", Int32.MinValue, Convert.ToInt32 ("80000000", 16));
+ AssertEquals ("-2147483648,10", Int32.MinValue, Convert.ToInt32 ("-2147483648", 10));
+ AssertEquals ("20000000000,8", Int32.MinValue, Convert.ToInt32 ("20000000000", 8));
+ AssertEquals ("10000000000000000000000000000000,2", Int32.MinValue, Convert.ToInt32 ("10000000000000000000000000000000", 2));
+ }
+
+ [Test]
+ public void ToInt64_MaxValue ()
+ {
+ AssertEquals ("7fffffffffffffff,16", Int64.MaxValue, Convert.ToInt64 ("7fffffffffffffff", 16));
+ AssertEquals ("9223372036854775807,10", Int64.MaxValue, Convert.ToInt64 ("9223372036854775807", 10));
+ AssertEquals ("777777777777777777777,8", Int64.MaxValue, Convert.ToInt64 ("777777777777777777777", 8));
+ AssertEquals ("111111111111111111111111111111111111111111111111111111111111111,2", Int64.MaxValue, Convert.ToInt64 ("111111111111111111111111111111111111111111111111111111111111111", 2));
+ }
+
+ [Test]
+ public void ToInt64_MinValue ()
+ {
+ AssertEquals ("8000000000000000,16", Int64.MinValue, Convert.ToInt64 ("8000000000000000", 16));
+ AssertEquals ("-9223372036854775808,10", Int64.MinValue, Convert.ToInt64 ("-9223372036854775808", 10));
+ AssertEquals ("1000000000000000000000,8", Int64.MinValue, Convert.ToInt64 ("1000000000000000000000", 8));
+ AssertEquals ("1000000000000000000000000000000000000000000000000000000000000000,2", Int64.MinValue, Convert.ToInt64 ("1000000000000000000000000000000000000000000000000000000000000000", 2));
+ }
+
+ // signed types
+
+ [Test]
+ [ExpectedException (typeof (OverflowException))]
+ public void ToSByte_OverMaxValue ()
+ {
+ string max_plus1 = "128";
+ Convert.ToSByte (max_plus1);
+ }
+
+ [Test]
+ [ExpectedException (typeof (OverflowException))]
+ public void ToSByte_OverMinValue ()
+ {
+ string min_minus1 = "-129";
+ Convert.ToSByte (min_minus1);
+ }
+
+ [Test]
+ [ExpectedException (typeof (OverflowException))]
+ public void ToInt16_OverMaxValue ()
+ {
+ string max_plus1 = "32768";
+ Convert.ToInt16 (max_plus1);
+ }
+
+ [Test]
+ [ExpectedException (typeof (OverflowException))]
+ public void ToInt16_OverMinValue ()
+ {
+ string min_minus1 = "-32769";
+ Convert.ToInt16 (min_minus1);
+ }
+
+ [Test]
+ [ExpectedException (typeof (OverflowException))]
+ public void ToInt32_OverMaxValue ()
+ {
+ string max_plus1 = "2147483648";
+ Convert.ToInt32 (max_plus1);
+ }
+
+ [Test]
+ [ExpectedException (typeof (OverflowException))]
+ public void ToInt32_OverMinValue ()
+ {
+ string min_minus1 = "-2147483649";
+ Convert.ToInt32 (min_minus1);
+ }
+
+ [Test]
+ [ExpectedException (typeof (OverflowException))]
+ public void ToInt64_OverMaxValue ()
+ {
+ string max_plus1 = "9223372036854775808";
+ Convert.ToInt64 (max_plus1);
+ }
+
+ [Test]
+ [ExpectedException (typeof (OverflowException))]
+ public void ToInt64_OverMinValue ()
+ {
+ string min_minus1 = "-9223372036854775809";
+ Convert.ToInt64 (min_minus1);
+ }
+
+ // unsigned types
+
+ [Test]
+ [ExpectedException (typeof (OverflowException))]
+ public void ToByte_OverMaxValue ()
+ {
+ string max_plus1 = "257";
+ Convert.ToByte (max_plus1);
+ }
+
+ [Test]
+ [ExpectedException (typeof (OverflowException))]
+ public void ToByte_OverMinValue ()
+ {
+ string min_minus1 = "-1";
+ Convert.ToByte (min_minus1);
+ }
+
+ [Test]
+ [ExpectedException (typeof (OverflowException))]
+ public void ToUInt16_OverMaxValue ()
+ {
+ string max_plus1 = "65536";
+ Convert.ToUInt16 (max_plus1);
+ }
+
+ [Test]
+ [ExpectedException (typeof (OverflowException))]
+ public void ToUInt16_OverMinValue ()
+ {
+ string min_minus1 = "-1";
+ Convert.ToUInt16 (min_minus1);
+ }
+
+ [Test]
+ [ExpectedException (typeof (OverflowException))]
+ public void ToUInt32_OverMaxValue ()
+ {
+ string max_plus1 = "4294967296";
+ Convert.ToUInt32 (max_plus1);
+ }
+
+ [Test]
+ [ExpectedException (typeof (OverflowException))]
+ public void ToUInt32_OverMinValue ()
+ {
+ string min_minus1 = "-1";
+ Convert.ToUInt32 (min_minus1);
+ }
+
+ [Test]
+ [ExpectedException (typeof (OverflowException))]
+ public void ToUInt64_OverMaxValue ()
+ {
+ string max_plus1 = "18446744073709551616";
+ Convert.ToUInt64 (max_plus1);
+ }
+
+ [Test]
+ [ExpectedException (typeof (OverflowException))]
+ public void ToUInt64_OverMinValue ()
+ {
+ string min_minus1 = "-1";
+ Convert.ToUInt64 (min_minus1);
+ }
+
+ [Test]
+ public void To_NullString ()
+ {
+ string s = null;
+ // signed
+ AssertEquals ("ToSByte", 0, Convert.ToSByte (s));
+ AssertEquals ("ToSByte+base", 0, Convert.ToSByte (s, 10));
+ AssertEquals ("ToInt16", 0, Convert.ToInt16 (s));
+ AssertEquals ("ToInt16+base", 0, Convert.ToInt16 (s, 10));
+ AssertEquals ("ToInt32", 0, Convert.ToInt32 (s));
+ AssertEquals ("ToInt32+base", 0, Convert.ToInt32 (s, 10));
+ AssertEquals ("ToInt64", 0, Convert.ToInt64 (s));
+ AssertEquals ("ToInt64+base", 0, Convert.ToInt64 (s, 10));
+ // unsigned
+ AssertEquals ("ToByte", 0, Convert.ToByte (s));
+ AssertEquals ("ToByte+base", 0, Convert.ToByte (s, 10));
+ AssertEquals ("ToUInt16", 0, Convert.ToUInt16 (s));
+ AssertEquals ("ToUInt16+base", 0, Convert.ToUInt16 (s, 10));
+ AssertEquals ("ToUInt32", 0, Convert.ToUInt32 (s));
+ AssertEquals ("ToUInt32+base", 0, Convert.ToUInt32 (s, 10));
+ AssertEquals ("ToUInt64", 0, Convert.ToUInt64 (s));
+ AssertEquals ("ToUInt64+base", 0, Convert.ToUInt64 (s, 10));
+ }
+
+ [Test]
+ public void To_NullObject ()
+ {
+ object o = null;
+ // signed
+ AssertEquals ("ToSByte", 0, Convert.ToSByte (o));
+ AssertEquals ("ToInt16", 0, Convert.ToInt16 (o));
+ AssertEquals ("ToInt32", 0, Convert.ToInt32 (o));
+ AssertEquals ("ToInt64", 0, Convert.ToInt64 (o));
+ // unsigned
+ AssertEquals ("ToByte", 0, Convert.ToByte (o));
+ AssertEquals ("ToUInt16", 0, Convert.ToUInt16 (o));
+ AssertEquals ("ToUInt32", 0, Convert.ToUInt32 (o));
+ AssertEquals ("ToUInt64", 0, Convert.ToUInt64 (o));
+ }
+
+ [Test]
+ public void To_NullObjectFormatProvider ()
+ {
+ object o = null;
+ IFormatProvider fp = (IFormatProvider) new NumberFormatInfo ();
+ // signed
+ AssertEquals ("ToSByte", 0, Convert.ToSByte (o, fp));
+ AssertEquals ("ToInt16", 0, Convert.ToInt16 (o, fp));
+ AssertEquals ("ToInt32", 0, Convert.ToInt32 (o, fp));
+ AssertEquals ("ToInt64", 0, Convert.ToInt64 (o, fp));
+ // unsigned
+ AssertEquals ("ToByte", 0, Convert.ToByte (o, fp));
+ AssertEquals ("ToUInt16", 0, Convert.ToUInt16 (o, fp));
+ AssertEquals ("ToUInt32", 0, Convert.ToUInt32 (o, fp));
+ AssertEquals ("ToUInt64", 0, Convert.ToUInt64 (o, fp));
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void ToSByte_NullStringFormatProvider ()
+ {
+ string s = null;
+ // SByte is a "special" case ???
+ Convert.ToSByte (s, new NumberFormatInfo ());
+ }
+
+ [Test]
+ public void To_NullStringFormatProvider ()
+ {
+ string s = null;
+ IFormatProvider fp = (IFormatProvider) new NumberFormatInfo ();
+ // signed
+ // No SByte here
+ AssertEquals ("ToInt16", 0, Convert.ToInt16 (s, fp));
+ AssertEquals ("ToInt32", 0, Convert.ToInt32 (s, fp));
+ AssertEquals ("ToInt64", 0, Convert.ToInt64 (s, fp));
+ // unsigned
+ AssertEquals ("ToByte", 0, Convert.ToByte (s, fp));
+ AssertEquals ("ToUInt16", 0, Convert.ToUInt16 (s, fp));
+ AssertEquals ("ToUInt32", 0, Convert.ToUInt32 (s, fp));
+ AssertEquals ("ToUInt64", 0, Convert.ToUInt64 (s, fp));
+ }
+
+ [Test]
+ [ExpectedException (typeof (InvalidCastException))]
+ public void ChangeTypeToTypeCodeEmpty ()
+ {
+ Convert.ChangeType (true, TypeCode.Empty);
+ }
+
+ [Test]
+ [ExpectedException (typeof (NullReferenceException))]
+ public void ChangeTypeNullToValuetype ()
+ {
+ Convert.ChangeType (null, typeof (int));
+ }
+
+ [Test]
+ public void ToString_MinMax_WithBase ()
+ {
+ AssertEquals ("Byte.MinValue base 2", "0", Convert.ToString (Byte.MinValue, 2));
+ AssertEquals ("Byte.MinValue base 8", "0", Convert.ToString (Byte.MinValue, 8));
+ AssertEquals ("Byte.MinValue base 10", "0", Convert.ToString (Byte.MinValue, 10));
+ AssertEquals ("Byte.MinValue base 16", "0", Convert.ToString (Byte.MinValue, 16));
+
+ AssertEquals ("Byte.MaxValue base 2", "11111111", Convert.ToString (Byte.MaxValue, 2));
+ AssertEquals ("Byte.MaxValue base 8", "377", Convert.ToString (Byte.MaxValue, 8));
+ AssertEquals ("Byte.MaxValue base 10", "255", Convert.ToString (Byte.MaxValue, 10));
+ AssertEquals ("Byte.MaxValue base 16", "ff", Convert.ToString (Byte.MaxValue, 16));
+
+ AssertEquals ("Int16.MinValue base 2", "1000000000000000", Convert.ToString (Int16.MinValue, 2));
+ AssertEquals ("Int16.MinValue base 8", "100000", Convert.ToString (Int16.MinValue, 8));
+ AssertEquals ("Int16.MinValue base 10", "-32768", Convert.ToString (Int16.MinValue, 10));
+ AssertEquals ("Int16.MinValue base 16", "8000", Convert.ToString (Int16.MinValue, 16));
+
+ AssertEquals ("Int16.MaxValue base 2", "111111111111111", Convert.ToString (Int16.MaxValue, 2));
+ AssertEquals ("Int16.MaxValue base 8", "77777", Convert.ToString (Int16.MaxValue, 8));
+ AssertEquals ("Int16.MaxValue base 10", "32767", Convert.ToString (Int16.MaxValue, 10));
+ AssertEquals ("Int16.MaxValue base 16", "7fff", Convert.ToString (Int16.MaxValue, 16));
+
+ AssertEquals ("Int32.MinValue base 2", "10000000000000000000000000000000", Convert.ToString (Int32.MinValue, 2));
+ AssertEquals ("Int32.MinValue base 8", "20000000000", Convert.ToString (Int32.MinValue, 8));
+ AssertEquals ("Int32.MinValue base 10", "-2147483648", Convert.ToString (Int32.MinValue, 10));
+ AssertEquals ("Int32.MinValue base 16", "80000000", Convert.ToString (Int32.MinValue, 16));
+
+ AssertEquals ("Int32.MaxValue base 2", "1111111111111111111111111111111", Convert.ToString (Int32.MaxValue, 2));
+ AssertEquals ("Int32.MaxValue base 8", "17777777777", Convert.ToString (Int32.MaxValue, 8));
+ AssertEquals ("Int32.MaxValue base 10", "2147483647", Convert.ToString (Int32.MaxValue, 10));
+ AssertEquals ("Int32.MaxValue base 16", "7fffffff", Convert.ToString (Int32.MaxValue, 16));
+
+ AssertEquals ("Int64.MinValue base 2", "1000000000000000000000000000000000000000000000000000000000000000", Convert.ToString (Int64.MinValue, 2));
+ AssertEquals ("Int64.MinValue base 8", "1000000000000000000000", Convert.ToString (Int64.MinValue, 8));
+ AssertEquals ("Int64.MinValue base 10", "-9223372036854775808", Convert.ToString (Int64.MinValue, 10));
+ AssertEquals ("Int64.MinValue base 16", "8000000000000000", Convert.ToString (Int64.MinValue, 16));
+
+ AssertEquals ("Int64.MaxValue base 2", "111111111111111111111111111111111111111111111111111111111111111", Convert.ToString (Int64.MaxValue, 2));
+ AssertEquals ("Int64.MaxValue base 8", "777777777777777777777", Convert.ToString (Int64.MaxValue, 8));
+ AssertEquals ("Int64.MaxValue base 10", "9223372036854775807", Convert.ToString (Int64.MaxValue, 10));
+ AssertEquals ("Int64.MaxValue base 16", "7fffffffffffffff", Convert.ToString (Int64.MaxValue, 16));
}
}
}