From 44334fdc98873eb3670bdb11134d66eb65c3eb5c Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Thu, 14 Jul 2005 19:52:31 +0000 Subject: [PATCH] [34715][lang] unit test for org.apache.commons.lang.text.StrBuilder. Patch applied, thanks. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@219083 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/commons/lang/text/StrBuilder.java | 10 ++++++---- .../org/apache/commons/lang/text/StrBuilderTest.java | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/java/org/apache/commons/lang/text/StrBuilder.java b/src/java/org/apache/commons/lang/text/StrBuilder.java index b0b46228f..6b7dbf632 100644 --- a/src/java/org/apache/commons/lang/text/StrBuilder.java +++ b/src/java/org/apache/commons/lang/text/StrBuilder.java @@ -589,10 +589,11 @@ public class StrBuilder implements Cloneable { if (coll != null && coll.size() > 0) { separator = (separator == null ? "" : separator); Iterator it = coll.iterator(); - append(it.next()); while (it.hasNext()) { - append(separator); append(it.next()); + if (it.hasNext()) { + append(separator); + } } } return this; @@ -611,10 +612,11 @@ public class StrBuilder implements Cloneable { public StrBuilder appendWithSeparators(Iterator it, String separator) { if (it != null) { separator = (separator == null ? "" : separator); - append(it.next()); while (it.hasNext()) { - append(separator); append(it.next()); + if (it.hasNext()) { + append(separator); + } } } return this; diff --git a/src/test/org/apache/commons/lang/text/StrBuilderTest.java b/src/test/org/apache/commons/lang/text/StrBuilderTest.java index 14660268b..87e70c781 100644 --- a/src/test/org/apache/commons/lang/text/StrBuilderTest.java +++ b/src/test/org/apache/commons/lang/text/StrBuilderTest.java @@ -567,7 +567,7 @@ public class StrBuilderTest extends TestCase { sb.clear(); sb.setNullText("null"); - sb.appendFixedWidthPadRight(null, 5, '-'); + sb.appendFixedWidthPadLeft(null, 5, '-'); assertEquals("-null", sb.toString()); }