Merge pull request #200 from ch5oh/master
[mono.git] / mcs / class / corlib / Test / System.Text / StringBuilderTest.cs
index 7941e04b5957849309bc56871a264922ac2db1f0..441171be03a84c6e9d3a800bebd527840fd29e6b 100644 (file)
@@ -79,7 +79,7 @@ namespace MonoTests.System.Text {
                                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]
@@ -491,6 +491,38 @@ namespace MonoTests.System.Text {
                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 ()
        {
@@ -501,6 +533,18 @@ namespace MonoTests.System.Text {
                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
+
 }
 
 }