X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2Fcorlib%2FTest%2FSystem%2FConvertTest.cs;h=8aee8a9cc657db1a0dc9cdd3bdeb26f77da10970;hb=cf7319008babd6a0bb0365331d6be575ff23aaa1;hp=d803e6da4e95739125651f28d017b76c679933dd;hpb=25981a0d42819c70496ee1a2a0622e0c4e7c6019;p=mono.git diff --git a/mcs/class/corlib/Test/System/ConvertTest.cs b/mcs/class/corlib/Test/System/ConvertTest.cs index d803e6da4e9..8aee8a9cc65 100644 --- a/mcs/class/corlib/Test/System/ConvertTest.cs +++ b/mcs/class/corlib/Test/System/ConvertTest.cs @@ -2696,6 +2696,13 @@ namespace MonoTests.System { Assert.AreEqual(116, result[3], "#A04"); } + [Test] + [ExpectedException (typeof (FormatException))] + public void TestInvalidBase64_TooManyPaddings () + { + Convert.FromBase64String ("dGVzd==="); + } + [Test] public void TestBeginWithSpaces () { @@ -2845,7 +2852,7 @@ namespace MonoTests.System { Assert.AreEqual (typeof(ArgumentOutOfRangeException), e.GetType(), "#T08"); } } -#if NET_2_0 + [Test] public void ToBase64String_Bug76876 () { @@ -2900,7 +2907,7 @@ namespace MonoTests.System { Assert.IsFalse (base64.Contains (Environment.NewLine), "58-nl"); // one lines Assert.IsTrue (base64.EndsWith ("AA=="), "58-le"); // no NewLine } -#endif + /* Have experienced some problems with FromBase64CharArray using mono. Something * about error in a unicode file. * @@ -2916,7 +2923,6 @@ namespace MonoTests.System { [Test] [ExpectedException (typeof (FormatException))] - [Category ("TargetJvmNotWorking")] public void FromBase64CharArray_Empty () { Convert.FromBase64CharArray (new char[0], 0, 0); @@ -2924,7 +2930,6 @@ namespace MonoTests.System { [Test] [ExpectedException (typeof (FormatException))] - [Category ("TargetJvmNotWorking")] public void FormatBase64CharArray_OnlyWhitespace () { Convert.FromBase64CharArray (new char[3] {' ', @@ -3054,23 +3059,15 @@ namespace MonoTests.System { } [Test] - [Category ("TargetJvmNotWorking")] public void FromBase64_Empty () { Assert.AreEqual (new byte[0], Convert.FromBase64String (string.Empty)); } [Test] -#if !NET_2_0 - [ExpectedException (typeof (FormatException))] -#endif public void FromBase64_OnlyWhiteSpace () { -#if NET_2_0 Assert.AreEqual (new byte[0], Convert.FromBase64String (" \r\t")); -#else - Convert.FromBase64String (" \r\t"); -#endif } [Test] @@ -3102,6 +3099,7 @@ namespace MonoTests.System { } } + [Test] public void TestConvertFromNull() { Assert.AreEqual (false, Convert.ToBoolean (null as object), "#W1"); @@ -3687,14 +3685,7 @@ namespace MonoTests.System { } [Test] - // 2005/01/10: The docs say this should throw an InvalidCastException, - // however, MS.NET 1.1 throws a NullReferenceException. Assuming docs - // are wrong. -#if NET_2_0 [ExpectedException (typeof (InvalidCastException))] -#else - [ExpectedException (typeof (NullReferenceException))] -#endif public void ChangeTypeNullToValuetype () { Convert.ChangeType (null, typeof (int)); @@ -4748,6 +4739,12 @@ namespace MonoTests.System { } } } + + [Test] + public void ToInt32_InvalidFormatProvider () + { + Assert.AreEqual (5, Convert.ToInt32 ("5", new InvalidFormatProvider ())); + } } public class Image @@ -4874,4 +4871,12 @@ namespace MonoTests.System { return (ulong)((IConvertible)this).ToType (typeof (ulong), provider); } } + + class InvalidFormatProvider : IFormatProvider + { + public object GetFormat (Type formatType) + { + return ""; + } + } }