Fixing Javadoc and adding Unit Test for the example for #LANG-261.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@411898 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Henri Yandell 2006-06-05 19:37:19 +00:00
parent 37b370c114
commit 80e957ecc4
2 changed files with 12 additions and 1 deletions

View File

@ -2197,7 +2197,7 @@ public class StringUtils {
* StringUtils.splitPreserveAllTokens(null, *) = null * StringUtils.splitPreserveAllTokens(null, *) = null
* StringUtils.splitPreserveAllTokens("", *) = [] * StringUtils.splitPreserveAllTokens("", *) = []
* StringUtils.splitPreserveAllTokens("a.b.c", '.') = ["a", "b", "c"] * StringUtils.splitPreserveAllTokens("a.b.c", '.') = ["a", "b", "c"]
* StringUtils.splitPreserveAllTokens("a..b.c", '.') = ["a", "b", "c"] * StringUtils.splitPreserveAllTokens("a..b.c", '.') = ["a", "", "b", "c"]
* StringUtils.splitPreserveAllTokens("a:b:c", '.') = ["a:b:c"] * StringUtils.splitPreserveAllTokens("a:b:c", '.') = ["a:b:c"]
* StringUtils.splitPreserveAllTokens("a\tb\nc", null) = ["a", "b", "c"] * StringUtils.splitPreserveAllTokens("a\tb\nc", null) = ["a", "b", "c"]
* StringUtils.splitPreserveAllTokens("a b c", ' ') = ["a", "b", "c"] * StringUtils.splitPreserveAllTokens("a b c", ' ') = ["a", "b", "c"]

View File

@ -581,6 +581,16 @@ public class StringUtilsTest extends TestCase {
assertEquals("b", res[3]); assertEquals("b", res[3]);
assertEquals("c", res[4]); assertEquals("c", res[4]);
// Match example in javadoc
{
String[] results = null;
String[] expectedResults = {"a", "", "b", "c"};
results = StringUtils.splitPreserveAllTokens("a..b.c",'.');
assertEquals(expectedResults.length, results.length);
for (int i = 0; i < expectedResults.length; i++) {
assertEquals(expectedResults[i], results[i]);
}
}
} }
public void testSplitPreserveAllTokens_StringString_StringStringInt() { public void testSplitPreserveAllTokens_StringString_StringStringInt() {
@ -710,6 +720,7 @@ public class StringUtilsTest extends TestCase {
assertEquals(expectedResults[i], results[i]); assertEquals(expectedResults[i], results[i]);
} }
} }
} }
private void innerTestSplitPreserveAllTokens(char separator, String sepStr, char noMatch) { private void innerTestSplitPreserveAllTokens(char separator, String sepStr, char noMatch) {