diff options
author | Tobias Thierer <tobiast@google.com> | 2018-05-31 18:51:38 +0100 |
---|---|---|
committer | Tobias Thierer <tobiast@google.com> | 2018-06-26 14:50:11 +0100 |
commit | e298436dd3876817820a6547b488382de7645305 (patch) | |
tree | 2417d44d60c576c0d3c12860ee2c144339ad8262 /harmony-tests | |
parent | 2cef2fdd535d6636f76c54cb870b02b0e5a93e0d (diff) |
Verify Pattern, step 2: Integrate behavior change for Pattern.split().
This is the second attempt to submit this CL. The first attempt broke
TextUtilsTest which is now updated by another CL in this topic; also,
the original CL changed behavior for all apps whereas this CL only
changes it for apps targeting API > 28.
This CL integrates a behavior change that was forgotten in the update
from OpenJDK 7u40 to 8u121-b13.
This CL also adds a test to guard against regressions.
Bug: 109659282
Test: testMatchBeginningOfInputSequence() fails before this CL, but
passes after this CL.
Test: cts-tradefed run singleCommand cts -a arm64-v8a -m CtsLibcoreTestCases \
-t org.apache.harmony.tests.java.util.regex.SplitTest
Test: cts-tradefed run singleCommand cts -a arm64-v8a -m CtsLibcoreTestCases \
-t org.apache.harmony.regex.tests.java.util.regex.PatternTest
Change-Id: Ic3631667de0b5cbc4531d42b342d752a701e822f
Diffstat (limited to 'harmony-tests')
-rw-r--r-- | harmony-tests/src/test/java/org/apache/harmony/tests/java/util/regex/SplitTest.java | 39 |
1 files changed, 10 insertions, 29 deletions
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/regex/SplitTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/regex/SplitTest.java index c40ef7c6f1..4818106f63 100644 --- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/regex/SplitTest.java +++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/regex/SplitTest.java @@ -17,13 +17,16 @@ package org.apache.harmony.tests.java.util.regex; +import java.util.Arrays; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; import junit.framework.TestCase; +import java.util.regex.*; /** * TODO Type description + * */ @SuppressWarnings("nls") public class SplitTest extends TestCase { @@ -174,45 +177,23 @@ public class SplitTest extends TestCase { public void testSplit2() { Pattern p = Pattern.compile(""); - String s[]; - s = p.split("a", -1); - assertEquals(3, s.length); - assertEquals("", s[0]); - assertEquals("a", s[1]); - assertEquals("", s[2]); - - s = p.split("", -1); - assertEquals(1, s.length); - assertEquals("", s[0]); - - s = p.split("abcd", -1); - assertEquals(6, s.length); - assertEquals("", s[0]); - assertEquals("a", s[1]); - assertEquals("b", s[2]); - assertEquals("c", s[3]); - assertEquals("d", s[4]); - assertEquals("", s[5]); + assertEquals(Arrays.asList("a", ""), Arrays.asList(p.split("a", -1))); + assertEquals(Arrays.asList(""), Arrays.asList(p.split("", -1))); + assertEquals(Arrays.asList("a", "b", "c", "d", ""), Arrays.asList(p.split("abcd", -1))); // Regression test for Android - assertEquals("GOOG,23,500".split("|").length, 12); + assertEquals("GOOG,23,500".split("|").length, 11); } public void testSplitSupplementaryWithEmptyString() { - /* * See http://www.unicode.org/reports/tr18/#Supplementary_Characters * We have to treat text as code points not code units. */ Pattern p = Pattern.compile(""); - String s[]; - s = p.split("a\ud869\uded6b", -1); - assertEquals(5, s.length); - assertEquals("", s[0]); - assertEquals("a", s[1]); - assertEquals("\ud869\uded6", s[2]); - assertEquals("b", s[3]); - assertEquals("", s[4]); + String[] s = p.split("a\ud869\uded6b", -1); + assertEquals(Arrays.asList("a", "\ud869\uded6", "b", ""), Arrays.asList(s)); } + } |