From 9abfbaecab79d19952544742c74450e1202e6240 Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Sat, 6 Mar 2010 22:54:34 +0000 Subject: [PATCH] More tests for length() git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@919872 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/commons/lang3/StringUtilsTest.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java index 0011f8ad9..e954a1e5b 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java @@ -23,10 +23,10 @@ import java.util.Collections; import java.util.Iterator; import java.util.Locale; -import org.apache.commons.lang3.text.WordUtils; - import junit.framework.TestCase; +import org.apache.commons.lang3.text.WordUtils; + /** * Unit tests {@link org.apache.commons.lang3.StringUtils}. * @@ -1296,7 +1296,7 @@ public class StringUtilsTest extends TestCase { assertEquals(" abc", StringUtils.leftPad("abc", 5, "")); } - public void testLength() { + public void testLengthString() { assertEquals(0, StringUtils.length(null)); assertEquals(0, StringUtils.length("")); assertEquals(0, StringUtils.length(StringUtils.EMPTY)); @@ -1304,6 +1304,22 @@ public class StringUtilsTest extends TestCase { assertEquals(1, StringUtils.length(" ")); assertEquals(8, StringUtils.length("ABCDEFGH")); } + + public void testLengthStringBuffer() { + assertEquals(0, StringUtils.length(new StringBuffer(""))); + assertEquals(0, StringUtils.length(new StringBuffer(StringUtils.EMPTY))); + assertEquals(1, StringUtils.length(new StringBuffer("A"))); + assertEquals(1, StringUtils.length(new StringBuffer(" "))); + assertEquals(8, StringUtils.length(new StringBuffer("ABCDEFGH"))); + } + + public void testLengthStringBuilder() { + assertEquals(0, StringUtils.length(new StringBuilder(""))); + assertEquals(0, StringUtils.length(new StringBuilder(StringUtils.EMPTY))); + assertEquals(1, StringUtils.length(new StringBuilder("A"))); + assertEquals(1, StringUtils.length(new StringBuilder(" "))); + assertEquals(8, StringUtils.length(new StringBuilder("ABCDEFGH"))); + } //----------------------------------------------------------------------- public void testCenter_StringInt() {