More tests for length()

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@919872 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary D. Gregory 2010-03-06 22:54:34 +00:00
parent 543f2d36e4
commit 9abfbaecab
1 changed files with 19 additions and 3 deletions

View File

@ -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() {