Skip to content

Commit

Permalink
backport r148706
Browse files Browse the repository at this point in the history
svn path=/branches/mono-2-6/mcs/; revision=148707
  • Loading branch information
Sebastien Pouliot committed Dec 17, 2009
1 parent 82f0bca commit 3a989e7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions mcs/class/corlib/System/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2009-12-17 Sebastien Pouliot <sebastien@ximian.com>

* String.cs: Fix #565602 right-padding empty strings.
[Backport r148706]

2009-12-09 Jb Evain <jbevain@novell.com>

* StringComparer.cs (GetHashCode): properly throw an
Expand Down
2 changes: 1 addition & 1 deletion mcs/class/corlib/System/String.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1531,7 +1531,7 @@ public unsafe String PadRight (int totalWidth, char paddingChar)

if (totalWidth < this.length)
return this;
if (this.Length == 0)
if (totalWidth == 0)
return String.Empty;

String tmp = InternalAllocateStr (totalWidth);
Expand Down
5 changes: 5 additions & 0 deletions mcs/class/corlib/Test/System/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2009-12-17 Sebastien Pouliot <sebastien@ximian.com>

* StringTest.cs: Add test case for right padding an empty string
[Backport r148706]

2009-11-24 Jb Evain <jbevain@novell.com>

* ArrayTest.cs: test that we don't allow the use of the IList indexer
Expand Down
7 changes: 7 additions & 0 deletions mcs/class/corlib/Test/System/StringTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3011,6 +3011,13 @@ public void PadRight1_TotalWidth_Negative ()
}
}

[Test]
public void PadRight2 ()
{
Assert.AreEqual ("100000000000", "1".PadRight (12, '0'), "#1");
Assert.AreEqual ("000000000000", "".PadRight (12, '0'), "#2");
}

[Test] // Remove (Int32, Int32)
public void Remove2 ()
{
Expand Down

0 comments on commit 3a989e7

Please sign in to comment.