Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8271302: Regex Test Refresh
Backport-of: fecefb8541d5056b1a8b105126ac9c566875e056
  • Loading branch information
TheRealMDoerr committed Mar 30, 2022
1 parent 7e41d84 commit ef42dbb
Show file tree
Hide file tree
Showing 3 changed files with 1,264 additions and 2,033 deletions.
22 changes: 12 additions & 10 deletions test/jdk/java/util/regex/GraphemeTest.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -26,23 +26,25 @@
* @bug 7071819 8221431 8239383
* @summary tests Unicode Extended Grapheme support
* @library /lib/testlibrary/java/lang
* @run main GraphemeTest
* @run testng GraphemeTest
*/

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.regex.Matcher;

import org.testng.annotations.Test;
import static org.testng.Assert.fail;

public class GraphemeTest {

public static void main(String[] args) throws Throwable {
@Test
public static void testGraphemeBreakProperty() throws Throwable {
testProps(UCDFiles.GRAPHEME_BREAK_PROPERTY);
}

@Test
public static void testEmojiData() throws Throwable {
testProps(UCDFiles.EMOJI_DATA);
}

Expand Down Expand Up @@ -78,7 +80,7 @@ private static void testProps(Path path) throws IOException {
System.out.printf("[%x] [%s][%d] -> [%s]%n",
cp, expected, Character.getType(cp), types[getType(cp)]);
else
throw new RuntimeException(String.format(
fail(String.format(
"cp=[%x], expeced:[%s] result:[%s]%n",
cp, expected, types[getType(cp)]));
}
Expand Down
16 changes: 8 additions & 8 deletions test/jdk/java/util/regex/NegativeArraySize.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -26,17 +26,17 @@
* @bug 8223174
* @summary Pattern.compile() can throw confusing NegativeArraySizeException
* @requires os.maxMemory >= 5g
* @run main/othervm NegativeArraySize -Xms5G -Xmx5G
* @run testng/othervm -Xms5G -Xmx5G NegativeArraySize
*/

import org.testng.annotations.Test;
import static org.testng.Assert.assertThrows;

import java.util.regex.Pattern;

public class NegativeArraySize {
public static void main(String[] args) {
try {
Pattern.compile("\\Q" + "a".repeat(42 + Integer.MAX_VALUE / 3));
throw new AssertionError("expected to throw");
} catch (OutOfMemoryError expected) {
}
@Test
public static void testNegativeArraySize() {
assertThrows(OutOfMemoryError.class, () -> Pattern.compile("\\Q" + "a".repeat(42 + Integer.MAX_VALUE / 3)));
}
}

1 comment on commit ef42dbb

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.