return;
}
// if we didn't catch an exception, then we have a problem Houston.
- NUnit.Framework.Assertion.Fail("Capacity exeeds MaxCapacity");
+ NUnit.Framework.Assertion.Fail("Capacity exceeds MaxCapacity");
}
[Test]
Assert.AreEqual ("abcaaDE", sb.ToString (), "#2");
}
+ [Test]
+ public void MaxCapacity_Overflow4 ()
+ {
+ StringBuilder sb = new StringBuilder (2, 3);
+ Assert.AreEqual (2, sb.Capacity);
+ Assert.AreEqual (3, sb.MaxCapacity);
+ try {
+ sb.Length = 4;
+ Assert.Fail ("#01");
+ } catch (ArgumentOutOfRangeException) {
+ }
+
+ try {
+ sb.EnsureCapacity (5);
+ Assert.Fail ("#02");
+ } catch (ArgumentOutOfRangeException) {
+ }
+ }
+
+ [Test]
+ public void NullInCtor ()
+ {
+ StringBuilder sb = null;
+ try {
+ sb = new StringBuilder (null, 10);
+ } catch (Exception e) {
+ Assert.Fail ("Should not throw #01");
+ }
+
+ Assert.IsTrue (sb.Length == 0);
+ }
+
[Test]
public void SetLength ()
{
Assert.AreEqual (8, sb.Length, "#3");
Assert.AreEqual ("Text\0\0\0\0", sb.ToString (), "#4");
}
+
+
+#if NET_4_0 || MOONLIGHT || MOBILE
+ [Test]
+ public void ClearMethod () {
+ StringBuilder sb = new StringBuilder ("Text");
+ sb.Clear ();
+ Assert.AreEqual (0, sb.Length, "#1");
+ Assert.AreEqual (String.Empty, sb.ToString (), "#2");
+ }
+#endif
+
}
}