Port to JUnit 4.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1183473 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary D. Gregory 2011-10-14 19:46:16 +00:00
parent eea29254e4
commit 7d00a80c97
1 changed files with 94 additions and 12 deletions

View File

@ -16,6 +16,14 @@
*/ */
package org.apache.commons.lang3; package org.apache.commons.lang3;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
@ -25,16 +33,15 @@ import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.Locale; import java.util.Locale;
import junit.framework.TestCase;
import org.apache.commons.lang3.text.WordUtils; import org.apache.commons.lang3.text.WordUtils;
import org.junit.Test;
/** /**
* Unit tests {@link org.apache.commons.lang3.StringUtils}. * Unit tests {@link org.apache.commons.lang3.StringUtils}.
* *
* @version $Id$ * @version $Id$
*/ */
public class StringUtilsTest extends TestCase { public class StringUtilsTest {
static final String WHITESPACE; static final String WHITESPACE;
static final String NON_WHITESPACE; static final String NON_WHITESPACE;
@ -91,11 +98,8 @@ public class StringUtilsTest extends TestCase {
private static final String SENTENCE_UNCAP = "foo bar baz"; private static final String SENTENCE_UNCAP = "foo bar baz";
private static final String SENTENCE_CAP = "Foo Bar Baz"; private static final String SENTENCE_CAP = "Foo Bar Baz";
public StringUtilsTest(String name) {
super(name);
}
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Test
public void testConstructor() { public void testConstructor() {
assertNotNull(new StringUtils()); assertNotNull(new StringUtils());
Constructor<?>[] cons = StringUtils.class.getDeclaredConstructors(); Constructor<?>[] cons = StringUtils.class.getDeclaredConstructors();
@ -106,6 +110,7 @@ public class StringUtilsTest extends TestCase {
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Test
public void testCaseFunctions() { public void testCaseFunctions() {
assertEquals(null, StringUtils.upperCase(null)); assertEquals(null, StringUtils.upperCase(null));
assertEquals(null, StringUtils.upperCase(null, Locale.ENGLISH)); assertEquals(null, StringUtils.upperCase(null, Locale.ENGLISH));
@ -157,6 +162,7 @@ public class StringUtilsTest extends TestCase {
"", StringUtils.lowerCase("", Locale.ENGLISH) ); "", StringUtils.lowerCase("", Locale.ENGLISH) );
} }
@Test
public void testSwapCase_String() { public void testSwapCase_String() {
assertEquals(null, StringUtils.swapCase(null)); assertEquals(null, StringUtils.swapCase(null));
assertEquals("", StringUtils.swapCase("")); assertEquals("", StringUtils.swapCase(""));
@ -175,12 +181,14 @@ public class StringUtilsTest extends TestCase {
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Test
public void testJoin_Objects() { public void testJoin_Objects() {
assertEquals("abc", StringUtils.join("a", "b", "c")); assertEquals("abc", StringUtils.join("a", "b", "c"));
assertEquals("a", StringUtils.join(null, "", "a")); assertEquals("a", StringUtils.join(null, "", "a"));
assertEquals(null, StringUtils.join((Object[])null)); assertEquals(null, StringUtils.join((Object[])null));
} }
@Test
public void testJoin_Objectarray() { public void testJoin_Objectarray() {
// assertEquals(null, StringUtils.join(null)); // generates warning // assertEquals(null, StringUtils.join(null)); // generates warning
assertEquals(null, StringUtils.join((Object[]) null)); // equivalent explicit cast assertEquals(null, StringUtils.join((Object[]) null)); // equivalent explicit cast
@ -197,6 +205,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("foo2", StringUtils.join(MIXED_TYPE_LIST)); assertEquals("foo2", StringUtils.join(MIXED_TYPE_LIST));
} }
@Test
public void testJoin_ArrayChar() { public void testJoin_ArrayChar() {
assertEquals(null, StringUtils.join((Object[]) null, ',')); assertEquals(null, StringUtils.join((Object[]) null, ','));
assertEquals(TEXT_LIST_CHAR, StringUtils.join(ARRAY_LIST, SEPARATOR_CHAR)); assertEquals(TEXT_LIST_CHAR, StringUtils.join(ARRAY_LIST, SEPARATOR_CHAR));
@ -212,6 +221,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("", StringUtils.join(MIXED_TYPE_LIST, '/', 2, 1)); assertEquals("", StringUtils.join(MIXED_TYPE_LIST, '/', 2, 1));
} }
@Test
public void testJoin_ArrayString() { public void testJoin_ArrayString() {
assertEquals(null, StringUtils.join((Object[]) null, null)); assertEquals(null, StringUtils.join((Object[]) null, null));
assertEquals(TEXT_LIST_NOSEP, StringUtils.join(ARRAY_LIST, null)); assertEquals(TEXT_LIST_NOSEP, StringUtils.join(ARRAY_LIST, null));
@ -235,6 +245,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("", StringUtils.join(MIXED_TYPE_LIST, "/", 2, 1)); assertEquals("", StringUtils.join(MIXED_TYPE_LIST, "/", 2, 1));
} }
@Test
public void testJoin_IteratorChar() { public void testJoin_IteratorChar() {
assertEquals(null, StringUtils.join((Iterator<?>) null, ',')); assertEquals(null, StringUtils.join((Iterator<?>) null, ','));
assertEquals(TEXT_LIST_CHAR, StringUtils.join(Arrays.asList(ARRAY_LIST).iterator(), SEPARATOR_CHAR)); assertEquals(TEXT_LIST_CHAR, StringUtils.join(Arrays.asList(ARRAY_LIST).iterator(), SEPARATOR_CHAR));
@ -243,6 +254,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("foo", StringUtils.join(Collections.singleton("foo").iterator(), 'x')); assertEquals("foo", StringUtils.join(Collections.singleton("foo").iterator(), 'x'));
} }
@Test
public void testJoin_IteratorString() { public void testJoin_IteratorString() {
assertEquals(null, StringUtils.join((Iterator<?>) null, null)); assertEquals(null, StringUtils.join((Iterator<?>) null, null));
assertEquals(TEXT_LIST_NOSEP, StringUtils.join(Arrays.asList(ARRAY_LIST).iterator(), null)); assertEquals(TEXT_LIST_NOSEP, StringUtils.join(Arrays.asList(ARRAY_LIST).iterator(), null));
@ -259,6 +271,7 @@ public class StringUtilsTest extends TestCase {
assertEquals(TEXT_LIST, StringUtils.join(Arrays.asList(ARRAY_LIST).iterator(), SEPARATOR)); assertEquals(TEXT_LIST, StringUtils.join(Arrays.asList(ARRAY_LIST).iterator(), SEPARATOR));
} }
@Test
public void testJoin_IterableChar() { public void testJoin_IterableChar() {
assertEquals(null, StringUtils.join((Iterable<?>) null, ',')); assertEquals(null, StringUtils.join((Iterable<?>) null, ','));
assertEquals(TEXT_LIST_CHAR, StringUtils.join(Arrays.asList(ARRAY_LIST), SEPARATOR_CHAR)); assertEquals(TEXT_LIST_CHAR, StringUtils.join(Arrays.asList(ARRAY_LIST), SEPARATOR_CHAR));
@ -267,6 +280,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("foo", StringUtils.join(Collections.singleton("foo"), 'x')); assertEquals("foo", StringUtils.join(Collections.singleton("foo"), 'x'));
} }
@Test
public void testJoin_IterableString() { public void testJoin_IterableString() {
assertEquals(null, StringUtils.join((Iterable<?>) null, null)); assertEquals(null, StringUtils.join((Iterable<?>) null, null));
assertEquals(TEXT_LIST_NOSEP, StringUtils.join(Arrays.asList(ARRAY_LIST), null)); assertEquals(TEXT_LIST_NOSEP, StringUtils.join(Arrays.asList(ARRAY_LIST), null));
@ -283,6 +297,7 @@ public class StringUtilsTest extends TestCase {
assertEquals(TEXT_LIST, StringUtils.join(Arrays.asList(ARRAY_LIST), SEPARATOR)); assertEquals(TEXT_LIST, StringUtils.join(Arrays.asList(ARRAY_LIST), SEPARATOR));
} }
@Test
public void testSplit_String() { public void testSplit_String() {
assertEquals(null, StringUtils.split(null)); assertEquals(null, StringUtils.split(null));
assertEquals(0, StringUtils.split("").length); assertEquals(0, StringUtils.split("").length);
@ -306,6 +321,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("b" + NON_WHITESPACE + "c", res[1]); assertEquals("b" + NON_WHITESPACE + "c", res[1]);
} }
@Test
public void testSplit_StringChar() { public void testSplit_StringChar() {
assertEquals(null, StringUtils.split(null, '.')); assertEquals(null, StringUtils.split(null, '.'));
assertEquals(0, StringUtils.split("", '.').length); assertEquals(0, StringUtils.split("", '.').length);
@ -330,6 +346,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("c", res[2]); assertEquals("c", res[2]);
} }
@Test
public void testSplit_StringString_StringStringInt() { public void testSplit_StringString_StringStringInt() {
assertEquals(null, StringUtils.split(null, ".")); assertEquals(null, StringUtils.split(null, "."));
assertEquals(null, StringUtils.split(null, ".", 3)); assertEquals(null, StringUtils.split(null, ".", 3));
@ -403,6 +420,7 @@ public class StringUtilsTest extends TestCase {
assertEquals(msg, str.substring(2), res[1]); assertEquals(msg, str.substring(2), res[1]);
} }
@Test
public void testSplitByWholeString_StringStringBoolean() { public void testSplitByWholeString_StringStringBoolean() {
assertEquals( null, StringUtils.splitByWholeSeparator( null, "." ) ) ; assertEquals( null, StringUtils.splitByWholeSeparator( null, "." ) ) ;
@ -434,6 +452,7 @@ public class StringUtilsTest extends TestCase {
} }
} }
@Test
public void testSplitByWholeString_StringStringBooleanInt() { public void testSplitByWholeString_StringStringBooleanInt() {
assertEquals( null, StringUtils.splitByWholeSeparator( null, ".", 3 ) ) ; assertEquals( null, StringUtils.splitByWholeSeparator( null, ".", 3 ) ) ;
@ -460,6 +479,7 @@ public class StringUtilsTest extends TestCase {
} }
} }
@Test
public void testSplitByWholeSeparatorPreserveAllTokens_StringStringInt() { public void testSplitByWholeSeparatorPreserveAllTokens_StringStringInt() {
assertEquals( null, StringUtils.splitByWholeSeparatorPreserveAllTokens( null, ".", -1 ) ) ; assertEquals( null, StringUtils.splitByWholeSeparatorPreserveAllTokens( null, ".", -1 ) ) ;
@ -506,6 +526,7 @@ public class StringUtilsTest extends TestCase {
} }
} }
@Test
public void testSplitPreserveAllTokens_String() { public void testSplitPreserveAllTokens_String() {
assertEquals(null, StringUtils.splitPreserveAllTokens(null)); assertEquals(null, StringUtils.splitPreserveAllTokens(null));
assertEquals(0, StringUtils.splitPreserveAllTokens("").length); assertEquals(0, StringUtils.splitPreserveAllTokens("").length);
@ -581,6 +602,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("b" + NON_WHITESPACE + "c", res[WHITESPACE.length()]); assertEquals("b" + NON_WHITESPACE + "c", res[WHITESPACE.length()]);
} }
@Test
public void testSplitPreserveAllTokens_StringChar() { public void testSplitPreserveAllTokens_StringChar() {
assertEquals(null, StringUtils.splitPreserveAllTokens(null, '.')); assertEquals(null, StringUtils.splitPreserveAllTokens(null, '.'));
assertEquals(0, StringUtils.splitPreserveAllTokens("", '.').length); assertEquals(0, StringUtils.splitPreserveAllTokens("", '.').length);
@ -692,6 +714,7 @@ public class StringUtilsTest extends TestCase {
} }
} }
@Test
public void testSplitPreserveAllTokens_StringString_StringStringInt() { public void testSplitPreserveAllTokens_StringString_StringStringInt() {
assertEquals(null, StringUtils.splitPreserveAllTokens(null, ".")); assertEquals(null, StringUtils.splitPreserveAllTokens(null, "."));
assertEquals(null, StringUtils.splitPreserveAllTokens(null, ".", 3)); assertEquals(null, StringUtils.splitPreserveAllTokens(null, ".", 3));
@ -866,6 +889,7 @@ public class StringUtilsTest extends TestCase {
assertEquals(msg, str.substring(2), res[1]); assertEquals(msg, str.substring(2), res[1]);
} }
@Test
public void testSplitByCharacterType() { public void testSplitByCharacterType() {
assertNull(StringUtils.splitByCharacterType(null)); assertNull(StringUtils.splitByCharacterType(null));
assertEquals(0, StringUtils.splitByCharacterType("").length); assertEquals(0, StringUtils.splitByCharacterType("").length);
@ -892,6 +916,7 @@ public class StringUtilsTest extends TestCase {
StringUtils.splitByCharacterType("ASFRules"))); StringUtils.splitByCharacterType("ASFRules")));
} }
@Test
public void testSplitByCharacterTypeCamelCase() { public void testSplitByCharacterTypeCamelCase() {
assertNull(StringUtils.splitByCharacterTypeCamelCase(null)); assertNull(StringUtils.splitByCharacterTypeCamelCase(null));
assertEquals(0, StringUtils.splitByCharacterTypeCamelCase("").length); assertEquals(0, StringUtils.splitByCharacterTypeCamelCase("").length);
@ -918,6 +943,7 @@ public class StringUtilsTest extends TestCase {
StringUtils.splitByCharacterTypeCamelCase("ASFRules"))); StringUtils.splitByCharacterTypeCamelCase("ASFRules")));
} }
@Test
public void testDeleteWhitespace_String() { public void testDeleteWhitespace_String() {
assertEquals(null, StringUtils.deleteWhitespace(null)); assertEquals(null, StringUtils.deleteWhitespace(null));
assertEquals("", StringUtils.deleteWhitespace("")); assertEquals("", StringUtils.deleteWhitespace(""));
@ -931,11 +957,13 @@ public class StringUtilsTest extends TestCase {
assertEquals("test", StringUtils.deleteWhitespace("\u000Bt \t\n\u0009e\rs\n\n \tt")); assertEquals("test", StringUtils.deleteWhitespace("\u000Bt \t\n\u0009e\rs\n\n \tt"));
} }
@Test
public void testLang623() { public void testLang623() {
assertEquals("t", StringUtils.replaceChars("\u00DE", '\u00DE', 't')); assertEquals("t", StringUtils.replaceChars("\u00DE", '\u00DE', 't'));
assertEquals("t", StringUtils.replaceChars("\u00FE", '\u00FE', 't')); assertEquals("t", StringUtils.replaceChars("\u00FE", '\u00FE', 't'));
} }
@Test
public void testReplace_StringStringString() { public void testReplace_StringStringString() {
assertEquals(null, StringUtils.replace(null, null, null)); assertEquals(null, StringUtils.replace(null, null, null));
assertEquals(null, StringUtils.replace(null, null, "any")); assertEquals(null, StringUtils.replace(null, null, "any"));
@ -957,6 +985,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("farfarfar", StringUtils.replace("foofoofoo", "oo", "ar")); assertEquals("farfarfar", StringUtils.replace("foofoofoo", "oo", "ar"));
} }
@Test
public void testReplace_StringStringStringInt() { public void testReplace_StringStringStringInt() {
assertEquals(null, StringUtils.replace(null, null, null, 2)); assertEquals(null, StringUtils.replace(null, null, null, 2));
assertEquals(null, StringUtils.replace(null, null, "any", 2)); assertEquals(null, StringUtils.replace(null, null, "any", 2));
@ -982,6 +1011,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("f", StringUtils.replace("oofoo", "o", "", 1000)); assertEquals("f", StringUtils.replace("oofoo", "o", "", 1000));
} }
@Test
public void testReplaceOnce_StringStringString() { public void testReplaceOnce_StringStringString() {
assertEquals(null, StringUtils.replaceOnce(null, null, null)); assertEquals(null, StringUtils.replaceOnce(null, null, null));
assertEquals(null, StringUtils.replaceOnce(null, null, "any")); assertEquals(null, StringUtils.replaceOnce(null, null, "any"));
@ -1004,9 +1034,8 @@ public class StringUtilsTest extends TestCase {
/** /**
* Test method for 'StringUtils.replaceEach(String, String[], String[])' * Test method for 'StringUtils.replaceEach(String, String[], String[])'
*/ */
@Test
public void testReplace_StringStringArrayStringArray() { public void testReplace_StringStringArrayStringArray() {
//JAVADOC TESTS START //JAVADOC TESTS START
assertNull(StringUtils.replaceEach(null, new String[]{"a"}, new String[]{"b"})); assertNull(StringUtils.replaceEach(null, new String[]{"a"}, new String[]{"b"}));
assertEquals(StringUtils.replaceEach("", new String[]{"a"}, new String[]{"b"}),""); assertEquals(StringUtils.replaceEach("", new String[]{"a"}, new String[]{"b"}),"");
@ -1040,6 +1069,7 @@ public class StringUtilsTest extends TestCase {
/** /**
* Test method for 'StringUtils.replaceEachRepeatedly(String, String[], String[])' * Test method for 'StringUtils.replaceEachRepeatedly(String, String[], String[])'
*/ */
@Test
public void testReplace_StringStringArrayStringArrayBoolean() { public void testReplace_StringStringArrayStringArrayBoolean() {
//JAVADOC TESTS START //JAVADOC TESTS START
assertNull(StringUtils.replaceEachRepeatedly(null, new String[]{"a"}, new String[]{"b"})); assertNull(StringUtils.replaceEachRepeatedly(null, new String[]{"a"}, new String[]{"b"}));
@ -1060,9 +1090,9 @@ public class StringUtilsTest extends TestCase {
} catch (IllegalStateException e) {} } catch (IllegalStateException e) {}
//JAVADOC TESTS END //JAVADOC TESTS END
} }
@Test
public void testReplaceChars_StringCharChar() { public void testReplaceChars_StringCharChar() {
assertEquals(null, StringUtils.replaceChars(null, 'b', 'z')); assertEquals(null, StringUtils.replaceChars(null, 'b', 'z'));
assertEquals("", StringUtils.replaceChars("", 'b', 'z')); assertEquals("", StringUtils.replaceChars("", 'b', 'z'));
@ -1070,6 +1100,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("abcba", StringUtils.replaceChars("abcba", 'x', 'z')); assertEquals("abcba", StringUtils.replaceChars("abcba", 'x', 'z'));
} }
@Test
public void testReplaceChars_StringStringString() { public void testReplaceChars_StringStringString() {
assertEquals(null, StringUtils.replaceChars(null, null, null)); assertEquals(null, StringUtils.replaceChars(null, null, null));
assertEquals(null, StringUtils.replaceChars(null, "", null)); assertEquals(null, StringUtils.replaceChars(null, "", null));
@ -1115,6 +1146,7 @@ public class StringUtilsTest extends TestCase {
"nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM567891234")); "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM567891234"));
} }
@Test
public void testOverlay_StringStringIntInt() { public void testOverlay_StringStringIntInt() {
assertEquals(null, StringUtils.overlay(null, null, 2, 4)); assertEquals(null, StringUtils.overlay(null, null, 2, 4));
assertEquals(null, StringUtils.overlay(null, null, -2, -4)); assertEquals(null, StringUtils.overlay(null, null, -2, -4));
@ -1142,6 +1174,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("abcdefzzzz", StringUtils.overlay("abcdef", "zzzz", 10, 8)); assertEquals("abcdefzzzz", StringUtils.overlay("abcdef", "zzzz", 10, 8));
} }
@Test
public void testRepeat_StringInt() { public void testRepeat_StringInt() {
assertEquals(null, StringUtils.repeat(null, 2)); assertEquals(null, StringUtils.repeat(null, 2));
assertEquals("", StringUtils.repeat("ab", 0)); assertEquals("", StringUtils.repeat("ab", 0));
@ -1154,6 +1187,7 @@ public class StringUtilsTest extends TestCase {
assertEquals(true, StringUtils.containsOnly(str, new char[] {'a'})); assertEquals(true, StringUtils.containsOnly(str, new char[] {'a'}));
} }
@Test
public void testRepeat_StringStringInt() { public void testRepeat_StringStringInt() {
assertEquals(null, StringUtils.repeat(null, null, 2)); assertEquals(null, StringUtils.repeat(null, null, 2));
assertEquals(null, StringUtils.repeat(null, "x", 2)); assertEquals(null, StringUtils.repeat(null, "x", 2));
@ -1167,6 +1201,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("?, ?, ?", StringUtils.repeat("?", ", ", 3)); assertEquals("?, ?, ?", StringUtils.repeat("?", ", ", 3));
} }
@Test
public void testChop() { public void testChop() {
String[][] chopCases = { String[][] chopCases = {
@ -1191,6 +1226,7 @@ public class StringUtilsTest extends TestCase {
} }
} }
@Test
public void testChomp() { public void testChomp() {
String[][] chompCases = { String[][] chompCases = {
@ -1249,6 +1285,7 @@ public class StringUtilsTest extends TestCase {
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Test
public void testRightPad_StringInt() { public void testRightPad_StringInt() {
assertEquals(null, StringUtils.rightPad(null, 5)); assertEquals(null, StringUtils.rightPad(null, 5));
assertEquals(" ", StringUtils.rightPad("", 5)); assertEquals(" ", StringUtils.rightPad("", 5));
@ -1257,6 +1294,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("abc", StringUtils.rightPad("abc", -1)); assertEquals("abc", StringUtils.rightPad("abc", -1));
} }
@Test
public void testRightPad_StringIntChar() { public void testRightPad_StringIntChar() {
assertEquals(null, StringUtils.rightPad(null, 5, ' ')); assertEquals(null, StringUtils.rightPad(null, 5, ' '));
assertEquals(" ", StringUtils.rightPad("", 5, ' ')); assertEquals(" ", StringUtils.rightPad("", 5, ' '));
@ -1269,6 +1307,7 @@ public class StringUtilsTest extends TestCase {
assertEquals(true, StringUtils.containsOnly(str, new char[] {'a'})); assertEquals(true, StringUtils.containsOnly(str, new char[] {'a'}));
} }
@Test
public void testRightPad_StringIntString() { public void testRightPad_StringIntString() {
assertEquals(null, StringUtils.rightPad(null, 5, "-+")); assertEquals(null, StringUtils.rightPad(null, 5, "-+"));
assertEquals(" ", StringUtils.rightPad("", 5, " ")); assertEquals(" ", StringUtils.rightPad("", 5, " "));
@ -1283,6 +1322,7 @@ public class StringUtilsTest extends TestCase {
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Test
public void testLeftPad_StringInt() { public void testLeftPad_StringInt() {
assertEquals(null, StringUtils.leftPad(null, 5)); assertEquals(null, StringUtils.leftPad(null, 5));
assertEquals(" ", StringUtils.leftPad("", 5)); assertEquals(" ", StringUtils.leftPad("", 5));
@ -1290,6 +1330,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("abc", StringUtils.leftPad("abc", 2)); assertEquals("abc", StringUtils.leftPad("abc", 2));
} }
@Test
public void testLeftPad_StringIntChar() { public void testLeftPad_StringIntChar() {
assertEquals(null, StringUtils.leftPad(null, 5, ' ')); assertEquals(null, StringUtils.leftPad(null, 5, ' '));
assertEquals(" ", StringUtils.leftPad("", 5, ' ')); assertEquals(" ", StringUtils.leftPad("", 5, ' '));
@ -1302,6 +1343,7 @@ public class StringUtilsTest extends TestCase {
assertEquals(true, StringUtils.containsOnly(str, new char[] {'a'})); assertEquals(true, StringUtils.containsOnly(str, new char[] {'a'}));
} }
@Test
public void testLeftPad_StringIntString() { public void testLeftPad_StringIntString() {
assertEquals(null, StringUtils.leftPad(null, 5, "-+")); assertEquals(null, StringUtils.leftPad(null, 5, "-+"));
assertEquals(null, StringUtils.leftPad(null, 5, null)); assertEquals(null, StringUtils.leftPad(null, 5, null));
@ -1315,6 +1357,7 @@ public class StringUtilsTest extends TestCase {
assertEquals(" abc", StringUtils.leftPad("abc", 5, "")); assertEquals(" abc", StringUtils.leftPad("abc", 5, ""));
} }
@Test
public void testLengthString() { public void testLengthString() {
assertEquals(0, StringUtils.length(null)); assertEquals(0, StringUtils.length(null));
assertEquals(0, StringUtils.length("")); assertEquals(0, StringUtils.length(""));
@ -1324,6 +1367,7 @@ public class StringUtilsTest extends TestCase {
assertEquals(8, StringUtils.length("ABCDEFGH")); assertEquals(8, StringUtils.length("ABCDEFGH"));
} }
@Test
public void testLengthStringBuffer() { public void testLengthStringBuffer() {
assertEquals(0, StringUtils.length(new StringBuffer(""))); assertEquals(0, StringUtils.length(new StringBuffer("")));
assertEquals(0, StringUtils.length(new StringBuffer(StringUtils.EMPTY))); assertEquals(0, StringUtils.length(new StringBuffer(StringUtils.EMPTY)));
@ -1332,6 +1376,7 @@ public class StringUtilsTest extends TestCase {
assertEquals(8, StringUtils.length(new StringBuffer("ABCDEFGH"))); assertEquals(8, StringUtils.length(new StringBuffer("ABCDEFGH")));
} }
@Test
public void testLengthStringBuilder() { public void testLengthStringBuilder() {
assertEquals(0, StringUtils.length(new StringBuilder(""))); assertEquals(0, StringUtils.length(new StringBuilder("")));
assertEquals(0, StringUtils.length(new StringBuilder(StringUtils.EMPTY))); assertEquals(0, StringUtils.length(new StringBuilder(StringUtils.EMPTY)));
@ -1340,6 +1385,7 @@ public class StringUtilsTest extends TestCase {
assertEquals(8, StringUtils.length(new StringBuilder("ABCDEFGH"))); assertEquals(8, StringUtils.length(new StringBuilder("ABCDEFGH")));
} }
@Test
public void testLength_CharBuffer() { public void testLength_CharBuffer() {
assertEquals(0, StringUtils.length(CharBuffer.wrap(""))); assertEquals(0, StringUtils.length(CharBuffer.wrap("")));
assertEquals(1, StringUtils.length(CharBuffer.wrap("A"))); assertEquals(1, StringUtils.length(CharBuffer.wrap("A")));
@ -1348,6 +1394,7 @@ public class StringUtilsTest extends TestCase {
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Test
public void testCenter_StringInt() { public void testCenter_StringInt() {
assertEquals(null, StringUtils.center(null, -1)); assertEquals(null, StringUtils.center(null, -1));
assertEquals(null, StringUtils.center(null, 4)); assertEquals(null, StringUtils.center(null, 4));
@ -1362,6 +1409,7 @@ public class StringUtilsTest extends TestCase {
assertEquals(" a ", StringUtils.center("a", 5)); assertEquals(" a ", StringUtils.center("a", 5));
} }
@Test
public void testCenter_StringIntChar() { public void testCenter_StringIntChar() {
assertEquals(null, StringUtils.center(null, -1, ' ')); assertEquals(null, StringUtils.center(null, -1, ' '));
assertEquals(null, StringUtils.center(null, 4, ' ')); assertEquals(null, StringUtils.center(null, 4, ' '));
@ -1377,6 +1425,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("xxaxx", StringUtils.center("a", 5, 'x')); assertEquals("xxaxx", StringUtils.center("a", 5, 'x'));
} }
@Test
public void testCenter_StringIntString() { public void testCenter_StringIntString() {
assertEquals(null, StringUtils.center(null, 4, null)); assertEquals(null, StringUtils.center(null, 4, null));
assertEquals(null, StringUtils.center(null, -1, " ")); assertEquals(null, StringUtils.center(null, -1, " "));
@ -1396,12 +1445,14 @@ public class StringUtilsTest extends TestCase {
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Test
public void testReverse_String() { public void testReverse_String() {
assertEquals(null, StringUtils.reverse(null) ); assertEquals(null, StringUtils.reverse(null) );
assertEquals("", StringUtils.reverse("") ); assertEquals("", StringUtils.reverse("") );
assertEquals("sdrawkcab", StringUtils.reverse("backwards") ); assertEquals("sdrawkcab", StringUtils.reverse("backwards") );
} }
@Test
public void testReverseDelimited_StringChar() { public void testReverseDelimited_StringChar() {
assertEquals(null, StringUtils.reverseDelimited(null, '.') ); assertEquals(null, StringUtils.reverseDelimited(null, '.') );
assertEquals("", StringUtils.reverseDelimited("", '.') ); assertEquals("", StringUtils.reverseDelimited("", '.') );
@ -1411,18 +1462,21 @@ public class StringUtilsTest extends TestCase {
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Test
public void testDefault_String() { public void testDefault_String() {
assertEquals("", StringUtils.defaultString(null)); assertEquals("", StringUtils.defaultString(null));
assertEquals("", StringUtils.defaultString("")); assertEquals("", StringUtils.defaultString(""));
assertEquals("abc", StringUtils.defaultString("abc")); assertEquals("abc", StringUtils.defaultString("abc"));
} }
@Test
public void testDefault_StringString() { public void testDefault_StringString() {
assertEquals("NULL", StringUtils.defaultString(null, "NULL")); assertEquals("NULL", StringUtils.defaultString(null, "NULL"));
assertEquals("", StringUtils.defaultString("", "NULL")); assertEquals("", StringUtils.defaultString("", "NULL"));
assertEquals("abc", StringUtils.defaultString("abc", "NULL")); assertEquals("abc", StringUtils.defaultString("abc", "NULL"));
} }
@Test
public void testDefaultIfEmpty_StringString() { public void testDefaultIfEmpty_StringString() {
assertEquals("NULL", StringUtils.defaultIfEmpty(null, "NULL")); assertEquals("NULL", StringUtils.defaultIfEmpty(null, "NULL"));
assertEquals("NULL", StringUtils.defaultIfEmpty("", "NULL")); assertEquals("NULL", StringUtils.defaultIfEmpty("", "NULL"));
@ -1433,6 +1487,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("abc", s); assertEquals("abc", s);
} }
@Test
public void testDefaultIfBlank_StringString() { public void testDefaultIfBlank_StringString() {
assertEquals("NULL", StringUtils.defaultIfBlank(null, "NULL")); assertEquals("NULL", StringUtils.defaultIfBlank(null, "NULL"));
assertEquals("NULL", StringUtils.defaultIfBlank("", "NULL")); assertEquals("NULL", StringUtils.defaultIfBlank("", "NULL"));
@ -1444,6 +1499,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("abc", s); assertEquals("abc", s);
} }
@Test
public void testDefaultIfEmpty_StringBuilders() { public void testDefaultIfEmpty_StringBuilders() {
assertEquals("NULL", StringUtils.defaultIfEmpty(new StringBuilder(""), new StringBuilder("NULL")).toString()); assertEquals("NULL", StringUtils.defaultIfEmpty(new StringBuilder(""), new StringBuilder("NULL")).toString());
assertEquals("abc", StringUtils.defaultIfEmpty(new StringBuilder("abc"), new StringBuilder("NULL")).toString()); assertEquals("abc", StringUtils.defaultIfEmpty(new StringBuilder("abc"), new StringBuilder("NULL")).toString());
@ -1453,6 +1509,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("abc", s.toString()); assertEquals("abc", s.toString());
} }
@Test
public void testDefaultIfBlank_StringBuilders() { public void testDefaultIfBlank_StringBuilders() {
assertEquals("NULL", StringUtils.defaultIfBlank(new StringBuilder(""), new StringBuilder("NULL")).toString()); assertEquals("NULL", StringUtils.defaultIfBlank(new StringBuilder(""), new StringBuilder("NULL")).toString());
assertEquals("NULL", StringUtils.defaultIfBlank(new StringBuilder(" "), new StringBuilder("NULL")).toString()); assertEquals("NULL", StringUtils.defaultIfBlank(new StringBuilder(" "), new StringBuilder("NULL")).toString());
@ -1463,6 +1520,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("abc", s.toString()); assertEquals("abc", s.toString());
} }
@Test
public void testDefaultIfEmpty_StringBuffers() { public void testDefaultIfEmpty_StringBuffers() {
assertEquals("NULL", StringUtils.defaultIfEmpty(new StringBuffer(""), new StringBuffer("NULL")).toString()); assertEquals("NULL", StringUtils.defaultIfEmpty(new StringBuffer(""), new StringBuffer("NULL")).toString());
assertEquals("abc", StringUtils.defaultIfEmpty(new StringBuffer("abc"), new StringBuffer("NULL")).toString()); assertEquals("abc", StringUtils.defaultIfEmpty(new StringBuffer("abc"), new StringBuffer("NULL")).toString());
@ -1472,6 +1530,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("abc", s.toString()); assertEquals("abc", s.toString());
} }
@Test
public void testDefaultIfBlank_StringBuffers() { public void testDefaultIfBlank_StringBuffers() {
assertEquals("NULL", StringUtils.defaultIfBlank(new StringBuffer(""), new StringBuffer("NULL")).toString()); assertEquals("NULL", StringUtils.defaultIfBlank(new StringBuffer(""), new StringBuffer("NULL")).toString());
assertEquals("NULL", StringUtils.defaultIfBlank(new StringBuffer(" "), new StringBuffer("NULL")).toString()); assertEquals("NULL", StringUtils.defaultIfBlank(new StringBuffer(" "), new StringBuffer("NULL")).toString());
@ -1482,6 +1541,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("abc", s.toString()); assertEquals("abc", s.toString());
} }
@Test
public void testDefaultIfEmpty_CharBuffers() { public void testDefaultIfEmpty_CharBuffers() {
assertEquals("NULL", StringUtils.defaultIfEmpty(CharBuffer.wrap(""), CharBuffer.wrap("NULL")).toString()); assertEquals("NULL", StringUtils.defaultIfEmpty(CharBuffer.wrap(""), CharBuffer.wrap("NULL")).toString());
assertEquals("abc", StringUtils.defaultIfEmpty(CharBuffer.wrap("abc"), CharBuffer.wrap("NULL")).toString()); assertEquals("abc", StringUtils.defaultIfEmpty(CharBuffer.wrap("abc"), CharBuffer.wrap("NULL")).toString());
@ -1491,6 +1551,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("abc", s.toString()); assertEquals("abc", s.toString());
} }
@Test
public void testDefaultIfBlank_CharBuffers() { public void testDefaultIfBlank_CharBuffers() {
assertEquals("NULL", StringUtils.defaultIfBlank(CharBuffer.wrap(""), CharBuffer.wrap("NULL")).toString()); assertEquals("NULL", StringUtils.defaultIfBlank(CharBuffer.wrap(""), CharBuffer.wrap("NULL")).toString());
assertEquals("NULL", StringUtils.defaultIfBlank(CharBuffer.wrap(" "), CharBuffer.wrap("NULL")).toString()); assertEquals("NULL", StringUtils.defaultIfBlank(CharBuffer.wrap(" "), CharBuffer.wrap("NULL")).toString());
@ -1502,6 +1563,7 @@ public class StringUtilsTest extends TestCase {
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Test
public void testAbbreviate_StringInt() { public void testAbbreviate_StringInt() {
assertEquals(null, StringUtils.abbreviate(null, 10)); assertEquals(null, StringUtils.abbreviate(null, 10));
assertEquals("", StringUtils.abbreviate("", 10)); assertEquals("", StringUtils.abbreviate("", 10));
@ -1527,6 +1589,7 @@ public class StringUtilsTest extends TestCase {
} }
} }
@Test
public void testAbbreviate_StringIntInt() { public void testAbbreviate_StringIntInt() {
assertEquals(null, StringUtils.abbreviate(null, 10, 12)); assertEquals(null, StringUtils.abbreviate(null, 10, 12));
assertEquals("", StringUtils.abbreviate("", 0, 10)); assertEquals("", StringUtils.abbreviate("", 0, 10));
@ -1587,6 +1650,7 @@ public class StringUtilsTest extends TestCase {
assertEquals(message, expected, actual); assertEquals(message, expected, actual);
} }
@Test
public void testAbbreviateMiddle() { public void testAbbreviateMiddle() {
// javadoc examples // javadoc examples
assertNull( StringUtils.abbreviateMiddle(null, null, 0) ); assertNull( StringUtils.abbreviateMiddle(null, null, 0) );
@ -1628,6 +1692,7 @@ public class StringUtilsTest extends TestCase {
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Test
public void testDifference_StringString() { public void testDifference_StringString() {
assertEquals(null, StringUtils.difference(null, null)); assertEquals(null, StringUtils.difference(null, null));
assertEquals("", StringUtils.difference("", "")); assertEquals("", StringUtils.difference("", ""));
@ -1640,6 +1705,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("you are a robot", StringUtils.difference("i am a robot", "you are a robot")); assertEquals("you are a robot", StringUtils.difference("i am a robot", "you are a robot"));
} }
@Test
public void testDifferenceAt_StringString() { public void testDifferenceAt_StringString() {
assertEquals(-1, StringUtils.indexOfDifference(null, null)); assertEquals(-1, StringUtils.indexOfDifference(null, null));
assertEquals(0, StringUtils.indexOfDifference(null, "i am a robot")); assertEquals(0, StringUtils.indexOfDifference(null, "i am a robot"));
@ -1654,6 +1720,7 @@ public class StringUtilsTest extends TestCase {
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Test
public void testGetLevenshteinDistance_StringString() { public void testGetLevenshteinDistance_StringString() {
assertEquals(0, StringUtils.getLevenshteinDistance("", "") ); assertEquals(0, StringUtils.getLevenshteinDistance("", "") );
assertEquals(1, StringUtils.getLevenshteinDistance("", "a") ); assertEquals(1, StringUtils.getLevenshteinDistance("", "a") );
@ -1681,6 +1748,7 @@ public class StringUtilsTest extends TestCase {
} }
} }
@Test
public void testGetLevenshteinDistance_StringStringInt() { public void testGetLevenshteinDistance_StringStringInt() {
// empty strings // empty strings
assertEquals(0, StringUtils.getLevenshteinDistance("", "", 0)); assertEquals(0, StringUtils.getLevenshteinDistance("", "", 0));
@ -1763,6 +1831,7 @@ public class StringUtilsTest extends TestCase {
/** /**
* A sanity check for {@link StringUtils#EMPTY}. * A sanity check for {@link StringUtils#EMPTY}.
*/ */
@Test
public void testEMPTY() { public void testEMPTY() {
assertNotNull(StringUtils.EMPTY); assertNotNull(StringUtils.EMPTY);
assertEquals("", StringUtils.EMPTY); assertEquals("", StringUtils.EMPTY);
@ -1772,6 +1841,7 @@ public class StringUtilsTest extends TestCase {
/** /**
* Test for {@link StringUtils#isAllLowerCase(CharSequence)}. * Test for {@link StringUtils#isAllLowerCase(CharSequence)}.
*/ */
@Test
public void testIsAllLowerCase() { public void testIsAllLowerCase() {
assertFalse(StringUtils.isAllLowerCase(null)); assertFalse(StringUtils.isAllLowerCase(null));
assertFalse(StringUtils.isAllLowerCase(StringUtils.EMPTY)); assertFalse(StringUtils.isAllLowerCase(StringUtils.EMPTY));
@ -1783,6 +1853,7 @@ public class StringUtilsTest extends TestCase {
/** /**
* Test for {@link StringUtils#isAllUpperCase(CharSequence)}. * Test for {@link StringUtils#isAllUpperCase(CharSequence)}.
*/ */
@Test
public void testIsAllUpperCase() { public void testIsAllUpperCase() {
assertFalse(StringUtils.isAllUpperCase(null)); assertFalse(StringUtils.isAllUpperCase(null));
assertFalse(StringUtils.isAllUpperCase(StringUtils.EMPTY)); assertFalse(StringUtils.isAllUpperCase(StringUtils.EMPTY));
@ -1791,6 +1862,7 @@ public class StringUtilsTest extends TestCase {
assertFalse(StringUtils.isAllUpperCase("aBC")); assertFalse(StringUtils.isAllUpperCase("aBC"));
} }
@Test
public void testRemoveStart() { public void testRemoveStart() {
// StringUtils.removeStart("", *) = "" // StringUtils.removeStart("", *) = ""
assertNull(StringUtils.removeStart(null, null)); assertNull(StringUtils.removeStart(null, null));
@ -1809,6 +1881,7 @@ public class StringUtilsTest extends TestCase {
assertEquals(StringUtils.removeStart("domain.com", null), "domain.com"); assertEquals(StringUtils.removeStart("domain.com", null), "domain.com");
} }
@Test
public void testRemoveStartIgnoreCase() { public void testRemoveStartIgnoreCase() {
// StringUtils.removeStart("", *) = "" // StringUtils.removeStart("", *) = ""
assertNull("removeStartIgnoreCase(null, null)", StringUtils.removeStartIgnoreCase(null, null)); assertNull("removeStartIgnoreCase(null, null)", StringUtils.removeStartIgnoreCase(null, null));
@ -1830,6 +1903,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("removeStartIgnoreCase(\"www.domain.com\", \"WWW.\")", StringUtils.removeStartIgnoreCase("www.domain.com", "WWW."), "domain.com"); assertEquals("removeStartIgnoreCase(\"www.domain.com\", \"WWW.\")", StringUtils.removeStartIgnoreCase("www.domain.com", "WWW."), "domain.com");
} }
@Test
public void testRemoveEnd() { public void testRemoveEnd() {
// StringUtils.removeEnd("", *) = "" // StringUtils.removeEnd("", *) = ""
assertNull(StringUtils.removeEnd(null, null)); assertNull(StringUtils.removeEnd(null, null));
@ -1849,6 +1923,7 @@ public class StringUtilsTest extends TestCase {
assertEquals(StringUtils.removeEnd("domain.com", null), "domain.com"); assertEquals(StringUtils.removeEnd("domain.com", null), "domain.com");
} }
@Test
public void testRemoveEndIgnoreCase() { public void testRemoveEndIgnoreCase() {
// StringUtils.removeEndIgnoreCase("", *) = "" // StringUtils.removeEndIgnoreCase("", *) = ""
assertNull("removeEndIgnoreCase(null, null)", StringUtils.removeEndIgnoreCase(null, null)); assertNull("removeEndIgnoreCase(null, null)", StringUtils.removeEndIgnoreCase(null, null));
@ -1872,6 +1947,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("removeEndIgnoreCase(\"www.domain.COM\", \".com\")", StringUtils.removeEndIgnoreCase("www.domain.COM", ".com"), "www.domain"); assertEquals("removeEndIgnoreCase(\"www.domain.COM\", \".com\")", StringUtils.removeEndIgnoreCase("www.domain.COM", ".com"), "www.domain");
} }
@Test
public void testRemove_String() { public void testRemove_String() {
// StringUtils.remove(null, *) = null // StringUtils.remove(null, *) = null
assertEquals(null, StringUtils.remove(null, null)); assertEquals(null, StringUtils.remove(null, null));
@ -1900,6 +1976,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("queued", StringUtils.remove("queued", "zz")); assertEquals("queued", StringUtils.remove("queued", "zz"));
} }
@Test
public void testRemove_char() { public void testRemove_char() {
// StringUtils.remove(null, *) = null // StringUtils.remove(null, *) = null
assertEquals(null, StringUtils.remove(null, 'a')); assertEquals(null, StringUtils.remove(null, 'a'));
@ -1918,7 +1995,8 @@ public class StringUtilsTest extends TestCase {
assertEquals("queued", StringUtils.remove("queued", 'z')); assertEquals("queued", StringUtils.remove("queued", 'z'));
} }
public void testDifferenceAt_StringArray(){ @Test
public void testDifferenceAt_StringArray() {
assertEquals(-1, StringUtils.indexOfDifference((String[])null)); assertEquals(-1, StringUtils.indexOfDifference((String[])null));
assertEquals(-1, StringUtils.indexOfDifference(new String[] {})); assertEquals(-1, StringUtils.indexOfDifference(new String[] {}));
assertEquals(-1, StringUtils.indexOfDifference(new String[] {"abc"})); assertEquals(-1, StringUtils.indexOfDifference(new String[] {"abc"}));
@ -1938,7 +2016,8 @@ public class StringUtilsTest extends TestCase {
assertEquals(7, StringUtils.indexOfDifference(new String[] {"i am a machine", "i am a robot"})); assertEquals(7, StringUtils.indexOfDifference(new String[] {"i am a machine", "i am a robot"}));
} }
public void testGetCommonPrefix_StringArray(){ @Test
public void testGetCommonPrefix_StringArray() {
assertEquals("", StringUtils.getCommonPrefix((String[])null)); assertEquals("", StringUtils.getCommonPrefix((String[])null));
assertEquals("", StringUtils.getCommonPrefix()); assertEquals("", StringUtils.getCommonPrefix());
assertEquals("abc", StringUtils.getCommonPrefix("abc")); assertEquals("abc", StringUtils.getCommonPrefix("abc"));
@ -1958,6 +2037,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("i am a ", StringUtils.getCommonPrefix("i am a machine", "i am a robot")); assertEquals("i am a ", StringUtils.getCommonPrefix("i am a machine", "i am a robot"));
} }
@Test
public void testNormalizeSpace() { public void testNormalizeSpace() {
assertEquals(null, StringUtils.normalizeSpace(null)); assertEquals(null, StringUtils.normalizeSpace(null));
assertEquals("", StringUtils.normalizeSpace("")); assertEquals("", StringUtils.normalizeSpace(""));
@ -1978,6 +2058,7 @@ public class StringUtilsTest extends TestCase {
assertEquals("a b c", StringUtils.normalizeSpace("a\t\f\r b\u000B c\n")); assertEquals("a b c", StringUtils.normalizeSpace("a\t\f\r b\u000B c\n"));
} }
@Test
public void testLANG666() { public void testLANG666() {
assertEquals("12",StringUtils.stripEnd("120.00", ".0")); assertEquals("12",StringUtils.stripEnd("120.00", ".0"));
assertEquals("121",StringUtils.stripEnd("121.00", ".0")); assertEquals("121",StringUtils.stripEnd("121.00", ".0"));
@ -1987,6 +2068,7 @@ public class StringUtilsTest extends TestCase {
// should take a CharSequence parameter. Methods that are mutable in spirit (i.e. capitalize) // should take a CharSequence parameter. Methods that are mutable in spirit (i.e. capitalize)
// should take a String or String[] parameter and return String or String[]. // should take a String or String[] parameter and return String or String[].
// This test enforces that this is done. // This test enforces that this is done.
@Test
public void testStringUtilsCharSequenceContract() { public void testStringUtilsCharSequenceContract() {
Class<StringUtils> c = StringUtils.class; Class<StringUtils> c = StringUtils.class;
Method[] methods = c.getMethods(); Method[] methods = c.getMethods();