LANG-1185 Add some tests for StringUtils replaceAll and replaceFirst methods

This commit is contained in:
Loic Guibert 2015-11-05 17:17:20 +04:00
parent b4842f559f
commit 242b815437
2 changed files with 6 additions and 2 deletions

View File

@ -4867,6 +4867,7 @@ public class StringUtils {
* StringUtils.replaceAll("", "", "zzz") = "zzz"
* StringUtils.replaceAll("", ".*", "zzz") = "zzz"
* StringUtils.replaceAll("", ".+", "zzz") = ""
* StringUtils.replaceAll("abc", "", "ZZ") = "ZZaZZbZZcZZ"
* StringUtils.replaceAll("<__>\n<__>", "<.*>", "z") = "z\nz"
* StringUtils.replaceAll("<__>\n<__>", "(?s)<.*>", "z") = "z"
* StringUtils.replaceAll("ABCabc123", "[a-z]", "_") = "ABC___123"
@ -4920,6 +4921,7 @@ public class StringUtils {
* StringUtils.replaceFirst("", "", "zzz") = "zzz"
* StringUtils.replaceFirst("", ".*", "zzz") = "zzz"
* StringUtils.replaceFirst("", ".+", "zzz") = ""
* StringUtils.replaceFirst("abc", "", "ZZ") = "ZZabc"
* StringUtils.replaceFirst("<__>\n<__>", "<.*>", "z") = "z\n<__>"
* StringUtils.replaceFirst("<__>\n<__>", "(?s)<.*>", "z") = "z"
* StringUtils.replaceFirst("ABCabc123", "[a-z]", "_") = "ABC_bc123"

View File

@ -1226,7 +1226,7 @@ public class StringUtilsTest {
}
@Test
public void testReplaceAll_StringStringString() {
public void testReplaceAll() {
assertNull(StringUtils.replaceAll(null, "", ""));
assertEquals("any", StringUtils.replaceAll("any", null, ""));
@ -1235,6 +1235,7 @@ public class StringUtilsTest {
assertEquals("zzz", StringUtils.replaceAll("", "", "zzz"));
assertEquals("zzz", StringUtils.replaceAll("", ".*", "zzz"));
assertEquals("", StringUtils.replaceAll("", ".+", "zzz"));
assertEquals("ZZaZZbZZcZZ", StringUtils.replaceAll("abc", "", "ZZ"));
assertEquals("z\nz", StringUtils.replaceAll("<__>\n<__>", "<.*>", "z"));
assertEquals("z", StringUtils.replaceAll("<__>\n<__>", "(?s)<.*>", "z"));
@ -1254,7 +1255,7 @@ public class StringUtilsTest {
}
@Test
public void testReplaceFirst_StringStringString() {
public void testReplaceFirst() {
assertNull(StringUtils.replaceFirst(null, "", ""));
assertEquals("any", StringUtils.replaceFirst("any", null, ""));
@ -1263,6 +1264,7 @@ public class StringUtilsTest {
assertEquals("zzz", StringUtils.replaceFirst("", "", "zzz"));
assertEquals("zzz", StringUtils.replaceFirst("", ".*", "zzz"));
assertEquals("", StringUtils.replaceFirst("", ".+", "zzz"));
assertEquals("ZZabc", StringUtils.replaceFirst("abc", "", "ZZ"));
assertEquals("z\n<__>", StringUtils.replaceFirst("<__>\n<__>", "<.*>", "z"));
assertEquals("z", StringUtils.replaceFirst("<__>\n<__>", "(?s)<.*>", "z"));