[mono-config] use right type for result of strlen
[mono.git] / mcs / class / corlib / Test / System / Int32Test.cs
index 128cc19790df3809993d52f43a8308e197ea9124..8d9a7fb03a02aa9bdcf2a1aff83ab6d1949fcaf3 100644 (file)
@@ -252,20 +252,40 @@ public class Int32Test
                        Assert.IsTrue (typeof (ArgumentException) == e.GetType (), "C#42");
                }
 
+               try {
+                       Int32.Parse ("5", NumberStyles.Any, CultureInfo.InvariantCulture);
+                       Assert.Fail ("C#42");
+               } catch (FormatException) {
+               }
+
+               try {
+                       Int32.Parse ("\xFF15\xFF15", NumberStyles.Any, CultureInfo.InvariantCulture);
+                       Assert.Fail ("C#43");
+               } catch (FormatException) {
+               }
+
                // Pass a DateTimeFormatInfo, it is unable to format
                // numbers, but we should not crash
                
                Int32.Parse ("123", new DateTimeFormatInfo ());
 
                Assert.AreEqual (734561, Int32.Parse ("734561\0"), "C#43");
-               Assert.AreEqual (734561, Int32.Parse ("734561\0\0\0    \0"), "C#44");
-               Assert.AreEqual (734561, Int32.Parse ("734561\0\0\0    "), "C#45");
+               try {
+                       Int32.Parse ("734561\0\0\0    \0");
+                       Assert.Fail ("C#44");
+               } catch (FormatException) {}
+
+               try {
+                       Int32.Parse ("734561\0\0\0    ");
+                       Assert.Fail ("C#45");
+               } catch (FormatException) {}
+
                Assert.AreEqual (734561, Int32.Parse ("734561\0\0\0"), "C#46");
 
                Assert.AreEqual (0, Int32.Parse ("0+", NumberStyles.Any), "#50");
        }
 
-    [Test]
+       [Test]
        public void TestParseExponent ()
        {
                Assert.AreEqual (2, Int32.Parse ("2E0", NumberStyles.AllowExponent), "A#1");
@@ -278,6 +298,7 @@ public class Int32Test
                Assert.AreEqual (520, Int32.Parse (".52E3", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#8");
                Assert.AreEqual (32500000, Int32.Parse ("32.5E6", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#9");
                Assert.AreEqual (890, Int32.Parse ("8.9000E2", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#10");
+               Assert.AreEqual (35, Int32.Parse ("3500E-02", NumberStyles.AllowExponent), "A#5");
 
                try {
                        Int32.Parse ("2E");
@@ -317,9 +338,9 @@ public class Int32Test
                }
 
                try {
-                       Int32.Parse ("2E-1", NumberStyles.AllowExponent); // negative exponent
+                       Int32.Parse ("2E-1", NumberStyles.AllowExponent);
                        Assert.Fail ("B#7");
-               } catch (OverflowException) {
+               } catch (OverflowException){
                }
 
                try {
@@ -332,7 +353,7 @@ public class Int32Test
                        Int32.Parse ("2.09E1",  NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent);
                        Assert.Fail ("B#9");
                } catch (OverflowException) {
-               }               
+               }
        }
 
        [Test]
@@ -391,6 +412,8 @@ public class Int32Test
                Assert.AreEqual (true, Int32.TryParse ("ffffffff", NumberStyles.HexNumber, Nfi, out result));
                Assert.AreEqual (-1, result);
                Assert.AreEqual (false, Int32.TryParse ("100000000", NumberStyles.HexNumber, Nfi, out result));
+               Assert.IsFalse (int.TryParse ("-", NumberStyles.AllowLeadingSign, Nfi, out result));
+               Assert.IsFalse (int.TryParse (Nfi.CurrencySymbol + "-", NumberStyles.AllowLeadingSign | NumberStyles.AllowCurrencySymbol, Nfi, out result));
        }
 
        [Test]