diff options
author | sherman <none@none> | 2013-11-13 22:22:28 -0800 |
---|---|---|
committer | sherman <none@none> | 2013-11-13 22:22:28 -0800 |
commit | 2fff6ba2c09e425bd4c9f837d347295892c7e7f7 (patch) | |
tree | cf845a6acd43f7bfab65b7413b943758439f70e9 /test | |
parent | 9ca9c13b549e9dd1920a51f03e54085bf8f218cd (diff) |
8028321: Fix for String.split() empty input sequence/JDK-6559590 triggers regression
Summary: to undo the change for 6559590
Reviewed-by: darcy
Diffstat (limited to 'test')
-rw-r--r-- | test/java/lang/String/Split.java | 4 | ||||
-rw-r--r-- | test/java/util/regex/RegExTest.java | 20 |
2 files changed, 16 insertions, 8 deletions
diff --git a/test/java/lang/String/Split.java b/test/java/lang/String/Split.java index 76a187841..d86f560a1 100644 --- a/test/java/lang/String/Split.java +++ b/test/java/lang/String/Split.java @@ -81,8 +81,10 @@ public class Split { // split() now returns 0-length for empty source "" see #6559590 source = ""; String[] result = source.split("e", 0); - if (result.length != 0) + if (result.length != 1) throw new RuntimeException("String.split failure 8"); + if (!result[0].equals(source)) + throw new RuntimeException("String.split failure 9"); // check fastpath of String.split() source = "0123456789abcdefgABCDEFG"; diff --git a/test/java/util/regex/RegExTest.java b/test/java/util/regex/RegExTest.java index f5282b27c..79e95772b 100644 --- a/test/java/util/regex/RegExTest.java +++ b/test/java/util/regex/RegExTest.java @@ -1781,7 +1781,9 @@ public class RegExTest { // split() now returns 0-length for empty source "" see #6559590 source = ""; result = source.split("e", 0); - if (result.length != 0) + if (result.length != 1) + failCount++; + if (!result[0].equals(source)) failCount++; // Check both split() and splitAsStraem(), especially for zero-lenth @@ -1817,8 +1819,8 @@ public class RegExTest { { "Abc", "Efg", "Hij" }, { "Abc", "Efg" }, { "Abc" }, - {}, - {}, + { "" }, + { "" }, { "awgqwefg1fefw", "vssv1vvv1" }, { "afbfq", "bgwgb", "wngnwggw", "", "hjrnhneerh" }, @@ -1826,7 +1828,7 @@ public class RegExTest { { "a\u4ebafg", "fefw\u4eba4\u9f9cvssv\u9f9c", "v\u672c\u672cvv" }, { "1", "23", "456", "7890" }, { "1", "23\u9f9c\u672c\u672c", "456", "\u9f9c\u672c7890" }, - {}, + { "" }, { "This", "is", "testing", "", "with", "different", "separators" }, { "b", "", ":and:f" }, { "b", "", "", "", "", ":and:f" }, @@ -1834,11 +1836,15 @@ public class RegExTest { }; for (int i = 0; i < input.length; i++) { pattern = Pattern.compile(input[i][0]); - if (!Arrays.equals(pattern.split(input[i][1]), expected[i])) + if (!Arrays.equals(pattern.split(input[i][1]), expected[i])) { failCount++; - if (!Arrays.equals(pattern.splitAsStream(input[i][1]).toArray(), - expected[i])) + } + if (input[i][1].length() > 0 && // splitAsStream() return empty resulting + // array for zero-length input for now + !Arrays.equals(pattern.splitAsStream(input[i][1]).toArray(), + expected[i])) { failCount++; + } } report("Split"); } |