< prev index next >

test/jdk/java/util/regex/RegExTest.java

Print this page
rev 58483 : [mq]: 8237599-Greedy-matching-against-supplementary-chars-does-not-respect-the-region

*** 34,44 **** * 7067045 7014640 7189363 8007395 8013252 8013254 8012646 8023647 6559590 * 8027645 8035076 8039124 8035975 8074678 6854417 8143854 8147531 7071819 * 8151481 4867170 7080302 6728861 6995635 6736245 4916384 6328855 6192895 * 6345469 6988218 6693451 7006761 8140212 8143282 8158482 8176029 8184706 * 8194667 8197462 8184692 8221431 8224789 8228352 8230829 8236034 8235812 ! * 8216332 8214245 * * @library /test/lib * @library /lib/testlibrary/java/lang * @build jdk.test.lib.RandomFactory * @run main RegExTest --- 34,44 ---- * 7067045 7014640 7189363 8007395 8013252 8013254 8012646 8023647 6559590 * 8027645 8035076 8039124 8035975 8074678 6854417 8143854 8147531 7071819 * 8151481 4867170 7080302 6728861 6995635 6736245 4916384 6328855 6192895 * 6345469 6988218 6693451 7006761 8140212 8143282 8158482 8176029 8184706 * 8194667 8197462 8184692 8221431 8224789 8228352 8230829 8236034 8235812 ! * 8216332 8214245 8237599 * * @library /test/lib * @library /lib/testlibrary/java/lang * @build jdk.test.lib.RandomFactory * @run main RegExTest
*** 193,202 **** --- 193,203 ---- invalidGroupName(); illegalRepetitionRange(); surrogatePairWithCanonEq(); lineBreakWithQuantifier(); caseInsensitivePMatch(); + surrogatePairOverlapRegion(); if (failure) { throw new RuntimeException("RegExTest failed, 1st failure: " + firstFailure);
*** 5153,5158 **** --- 5154,5200 ---- } } } report("caseInsensitivePMatch"); } + + // This test is for 8237599 + private static void surrogatePairOverlapRegion() { + String input = "\ud801\udc37"; + + Pattern p = Pattern.compile(".+"); + Matcher m = p.matcher(input); + m.region(0, 1); + + boolean ok = m.find(); + if (!ok || !m.group(0).equals(input.substring(0, 1))) + { + failCount++; + System.out.println("Input \"" + input + "\".substr(0, 1)" + + " expected to match pattern \"" + p + "\""); + if (ok) { + System.out.println("group(0): \"" + m.group(0) + "\""); + } + } else if (!m.hitEnd()) { + failCount++; + System.out.println("Expected m.hitEnd() == true"); + } + + p = Pattern.compile(".*(.)"); + m = p.matcher(input); + m.region(1, 2); + + ok = m.find(); + if (!ok || !m.group(0).equals(input.substring(1, 2)) + || !m.group(1).equals(input.substring(1, 2))) + { + failCount++; + System.out.println("Input \"" + input + "\".substr(1, 2)" + + " expected to match pattern \"" + p + "\""); + if (ok) { + System.out.println("group(0): \"" + m.group(0) + "\""); + System.out.println("group(1): \"" + m.group(1) + "\""); + } + } + report("surrogatePairOverlapRegion"); + } }
< prev index next >