+
+ [Test]
+ public void TestParseExponent ()
+ {
+ Assert.AreEqual (2, uint.Parse ("2E0", NumberStyles.AllowExponent), "A#1");
+ Assert.AreEqual (20, uint.Parse ("2E1", NumberStyles.AllowExponent), "A#2");
+ Assert.AreEqual (200, uint.Parse ("2E2", NumberStyles.AllowExponent), "A#3");
+ Assert.AreEqual (2000000, uint.Parse ("2E6", NumberStyles.AllowExponent), "A#4");
+ Assert.AreEqual (200, uint.Parse ("2E+2", NumberStyles.AllowExponent), "A#5");
+ Assert.AreEqual (2, uint.Parse ("2", NumberStyles.AllowExponent), "A#6");
+ Assert.AreEqual (21, uint.Parse ("2.1E1", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#7");
+ Assert.AreEqual (520, uint.Parse (".52E3", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#8");
+ Assert.AreEqual (32500000, uint.Parse ("32.5E6", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#9");
+ Assert.AreEqual (890, uint.Parse ("8.9000E2", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent), "A#10");
+
+ try {
+ uint.Parse ("2E");
+ Assert.Fail ("B#1");
+ } catch (FormatException) {
+ }
+
+ try {
+ uint.Parse ("2E3.0", NumberStyles.AllowExponent); // decimal notation for the exponent
+ Assert.Fail ("B#2");
+ } catch (FormatException) {
+ }
+
+ try {
+ uint.Parse ("2E 2", NumberStyles.AllowExponent);
+ Assert.Fail ("B#3");
+ } catch (FormatException) {
+ }
+
+ try {
+ uint.Parse ("2E2 ", NumberStyles.AllowExponent);
+ Assert.Fail ("B#4");
+ } catch (FormatException) {
+ }
+
+ try {
+ uint.Parse ("2E66", NumberStyles.AllowExponent); // final result overflow
+ Assert.Fail ("B#5");
+ } catch (OverflowException) {
+ }
+
+ try {
+ long exponent = (long) Int32.MaxValue + 10;
+ uint.Parse ("2E" + exponent.ToString (), NumberStyles.AllowExponent);
+ Assert.Fail ("B#6");
+ } catch (OverflowException) {
+ }
+
+ try {
+ uint.Parse ("2E-1", NumberStyles.AllowExponent); // negative exponent
+ Assert.Fail ("B#7");
+ } catch (OverflowException) {
+ }
+
+ try {
+ uint.Parse ("2 math e1", NumberStyles.AllowExponent);
+ Assert.Fail ("B#8");
+ } catch (FormatException) {
+ }
+
+ try {
+ uint.Parse ("2.09E1", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent);
+ Assert.Fail ("B#9");
+ } catch (OverflowException) {
+ }
+ }
+
+ [Test]