Applying a unit test for LANG-299 and the fix that Francisco Benavent suggests.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@486377 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Henri Yandell 2006-12-12 22:34:39 +00:00
parent aaaa779108
commit 9b0b19a916
2 changed files with 8 additions and 1 deletions

View File

@ -881,7 +881,7 @@ public StrBuilder appendFixedWidthPadRight(Object obj, int width, char padChar)
String str = (obj == null ? getNullText() : obj.toString());
int strLen = str.length();
if (strLen >= width) {
str.getChars(0, strLen, buffer, size);
str.getChars(0, width, buffer, size);
} else {
int padLen = width - strLen;
str.getChars(0, strLen, buffer, size);

View File

@ -596,6 +596,13 @@ public void testAppendFixedWidthPadRight() {
assertEquals("null-", sb.toString());
}
// See: http://issues.apache.org/jira/browse/LANG-299
public void testLang299() {
StrBuilder sb = new StrBuilder(1);
sb.appendFixedWidthPadRight("foo", 1, '-');
assertEquals("f", sb.toString());
}
//-----------------------------------------------------------------------
public void testAppendFixedWidthPadRight_int() {
StrBuilder sb = new StrBuilder();