Browse Source

2005-01-11 Gonzalo Paniagua Javier <[email protected]>

	* System.Text/StringBuilder.cs: when creating the StringBuilder from a
	string, the maximum capacity remains Int32.MaxValue.

	* Test/System.Text/StringBuilderTest.cs: new tests for capacity when
	the StringBuilder is created from a string.


svn path=/trunk/mcs/; revision=38734
Gonzalo Paniagua Javier 21 years ago
parent
commit
7eadde80f1

+ 5 - 0
mcs/class/corlib/System.Text/ChangeLog

@@ -1,3 +1,8 @@
+2005-01-11 Gonzalo Paniagua Javier <[email protected]>
+
+	* StringBuilder.cs: when creating the StringBuilder from a string, the
+	maximum capacity remains Int32.MaxValue.
+
 2005-01-10 Gonzalo Paniagua Javier <[email protected]>
 
 	* StringBuilder.cs: throw if the new size is greater than the maximum

+ 2 - 1
mcs/class/corlib/System.Text/StringBuilder.cs

@@ -94,7 +94,8 @@ namespace System.Text {
 			_maxCapacity = maxCapacity;
 		}
 
-		public StringBuilder( string value ) : this(value, 0, value == null ? 0 : value.Length, value == null? 0 : value.Length) {
+		public StringBuilder( string value ) : this() {
+			Append (value);
 		}
 	
 		public StringBuilder( string value, int capacity) : this(value, 0, value.Length, capacity) {}

+ 5 - 0
mcs/class/corlib/Test/System.Text/ChangeLog

@@ -1,3 +1,8 @@
+2005-01-11 Gonzalo Paniagua Javier <[email protected]>
+
+	* System.Text/StringBuilderTest.cs: new tests for capacity when the
+	StringBuilder is created from a string.
+
 2005-01-10 Gonzalo Paniagua Javier <[email protected]>
 
 	* StringBuilderTest.cs: patch to test for capacity being exceeded.

+ 10 - 0
mcs/class/corlib/Test/System.Text/StringBuilderTest.cs

@@ -442,6 +442,16 @@ namespace MonoTests.System.Text {
 		AssertEquals (2, sb.Capacity);
 		AssertEquals (3, sb.MaxCapacity);
 	}
+
+	[Test]
+	public void CapacityFromString ()
+	{
+		StringBuilder sb = new StringBuilder ("hola");
+		AssertEquals ("#01", 16, sb.Capacity);
+
+		sb = new StringBuilder ("01234567890123456789");
+		AssertEquals ("#02", 32, sb.Capacity);
+	}
 }
 
 }