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");
Int32.Parse ("2.09E1", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent);
Assert.Fail ("B#9");
} catch (OverflowException) {
- }
+ }
}
[Test]
int hundred = 100;
int neghund = -100;
- Assert.IsTrue ( hundred.ToString ("#;#") == "100", "#TS1");
- Assert.IsTrue ( hundred.ToString ("-#;#") == "-100", "#TS2");
- Assert.IsTrue ( neghund.ToString ("#;#") == "100", "#TS3");
- Assert.IsTrue ( neghund.ToString ("#;-#") == "-100", "#TS3");
+ Assert.AreEqual ("100", hundred.ToString ("#;#"), "#TS1");
+ Assert.AreEqual ("-100", hundred.ToString ("-#;#"), "#TS2");
+ Assert.AreEqual ("100", neghund.ToString ("#;#"), "#TS3");
+ Assert.AreEqual ("-100", neghund.ToString ("#;-#"), "#TS4");
+ Assert.AreEqual ("3", 0.ToString ("3;;"), "#TS5");
+ Assert.AreEqual ("3", 0.ToString ("3;2;"), "#TS6");
+ Assert.AreEqual ("3", 0.ToString ("3;"), "#TS7");
+ Assert.AreEqual ("3", 0.ToString ("3;;;;;;;"), "#TS8");
}
[Test]