+ Assert.IsTrue (typeof (OverflowException) == e.GetType (), "C#38");
+ }
+
+ try {
+ Int32.Parse (null);
+ Assert.Fail ("C#39: Should raise an ArgumentNullException");
+ } catch (Exception e){
+ Assert.IsTrue (typeof (ArgumentNullException) == e.GetType (), "C#40");
+ }
+
+ try {
+ Int32.Parse ("123", (NumberStyles) 60000);
+ Assert.Fail ("C#41 Should raise an ArgumentException");
+ } catch (Exception e){
+ Assert.IsTrue (typeof (ArgumentException) == e.GetType (), "C#42");
+ }
+
+ // 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");
+ Assert.AreEqual (734561, Int32.Parse ("734561\0\0\0"), "C#46");
+
+ Assert.AreEqual (0, Int32.Parse ("0+", NumberStyles.Any), "#50");
+ }
+
+ [Test]
+ public void TestParseExponent ()
+ {
+ Assert.AreEqual (2, Int32.Parse ("2E0", NumberStyles.AllowExponent), "A#1");
+ Assert.AreEqual (20, Int32.Parse ("2E1", NumberStyles.AllowExponent), "A#2");
+ Assert.AreEqual (200, Int32.Parse ("2E2", NumberStyles.AllowExponent), "A#3");
+ Assert.AreEqual (2000000, Int32.Parse ("2E6", NumberStyles.AllowExponent), "A#4");
+ Assert.AreEqual (200, Int32.Parse ("2E+2", NumberStyles.AllowExponent), "A#5");
+ Assert.AreEqual (2, Int32.Parse ("2", NumberStyles.AllowExponent), "A#6");
+ Assert.AreEqual (21, Int32.Parse ("2.1E1", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#7");
+ 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");
+
+ try {
+ Int32.Parse ("2E");
+ Assert.Fail ("B#1");
+ } catch (FormatException) {
+ }
+
+ try {
+ Int32.Parse ("2E3.0", NumberStyles.AllowExponent); // decimal notation for the exponent
+ Assert.Fail ("B#2");
+ } catch (FormatException) {
+ }
+
+ try {
+ Int32.Parse ("2E 2", NumberStyles.AllowExponent);
+ Assert.Fail ("B#3");
+ } catch (FormatException) {
+ }
+
+ try {
+ Int32.Parse ("2E2 ", NumberStyles.AllowExponent);
+ Assert.Fail ("B#4");
+ } catch (FormatException) {
+ }
+
+ try {
+ Int32.Parse ("2E66", NumberStyles.AllowExponent); // final result overflow
+ Assert.Fail ("B#5");
+ } catch (OverflowException) {
+ }
+
+ try {
+ long exponent = (long)Int32.MaxValue + 10;
+ Int32.Parse ("2E" + exponent.ToString (), NumberStyles.AllowExponent);
+ Assert.Fail ("B#6");
+ } catch (OverflowException) {
+ }
+
+ try {
+ Int32.Parse ("2E-1", NumberStyles.AllowExponent); // negative exponent
+ Assert.Fail ("B#7");
+ } catch (OverflowException) {