Add NUnit tests for bug #4814
[mono.git] / mcs / class / corlib / Test / System / DecimalTest.cs
index 3133ebf8d06684f892b186ced974e783e3ac163f..ef145ff11918cacc1212d56834ae85133b5c8557 100644 (file)
@@ -1454,5 +1454,75 @@ namespace MonoTests.System
                        Assert.AreEqual (-2.1M, Math.Round (-2.08M, 1, m), "#15");
                        Assert.AreEqual (-3.1M, Math.Round (-3.05M, 1, m), "#16");
                }
+
+               [Test] // bug #4814
+               [SetCulture("")]
+               public void Parse_NumberGroupSeparatorIsEmpty_DoNotThrowIndexOutOfRangeException ()
+               {
+                       NumberFormatInfo nf = new NumberFormatInfo ();
+                       nf.NumberGroupSeparator = "";
+                       Decimal.Parse ("1.5", nf);
+               }
+
+               [Test] // bug #4814
+               [SetCulture("")]
+               public void Parse_CurrencyGroupSeparatorIsEmpty_DoNotThrowIndexOutOfRangeException ()
+               {
+                       NumberFormatInfo nf = new NumberFormatInfo ();
+                       nf.CurrencyGroupSeparator = "";
+                       Decimal.Parse ("\u00A41.5", NumberStyles.Currency, nf);
+               }
+
+               [Test] // bug #4814
+               [SetCulture("")]
+               public void Parse_LeadingSign_PositiveSignIsEmpty_DoNotThrowIndexOutOfRangeException ()
+               {
+                       NumberFormatInfo nf = new NumberFormatInfo ();
+                       nf.PositiveSign = "";
+                       try {
+                               Decimal.Parse ("+15", nf);
+                       } catch (FormatException) {
+                               // ok
+                       }
+               }
+
+               [Test] // bug #4814
+               [SetCulture("")]
+               public void Parse_LeadingSign_NegativeSignIsEmpty_DoNotThrowIndexOutOfRangeException ()
+               {
+                       NumberFormatInfo nf = new NumberFormatInfo ();
+                       nf.NegativeSign = "";
+                       try {
+                               Decimal.Parse ("-15", nf);
+                       } catch (FormatException) {
+                               // ok
+                       }
+               }
+
+               [Test] // bug #4814
+               [SetCulture("")]
+               public void Parse_TrailingSign_PositiveSignIsEmpty_DoNotThrowIndexOutOfRangeException ()
+               {
+                       NumberFormatInfo nf = new NumberFormatInfo ();
+                       nf.PositiveSign = "";
+                       try {
+                               Decimal.Parse ("15+", nf);
+                       } catch (FormatException) {
+                               // ok
+                       }
+               }
+
+               [Test] // bug #4814
+               [SetCulture("")]
+               public void Parse_TrailingSign_NegativeSignIsEmpty_DoNotThrowIndexOutOfRangeException ()
+               {
+                       NumberFormatInfo nf = new NumberFormatInfo ();
+                       nf.NegativeSign = "";
+                       try {
+                               Decimal.Parse ("15-", nf);
+                       } catch (FormatException) {
+                               // ok
+                       }
+               }
        }
 }