[Git][java-team/re2j][upstream] New upstream version 1.8+dfsg
Emmanuel Bourg (@ebourg)
gitlab at salsa.debian.org
Fri Nov 13 18:25:23 GMT 2026
Emmanuel Bourg pushed to branch upstream at Debian Java Maintainers / re2j
Commits:
620457bb by Emmanuel Bourg at 2026-11-13T12:04:30+01:00
New upstream version 1.8+dfsg
- - - - -
17 changed files:
- RELEASING.md
- build.gradle
- java/com/google/re2j/Inst.java
- java/com/google/re2j/Matcher.java
- java/com/google/re2j/Parser.java
- java/com/google/re2j/Pattern.java
- java/com/google/re2j/RE2.java
- java/com/google/re2j/Regexp.java
- java/com/google/re2j/Unicode.java
- javatests/com/google/re2j/ApiTestUtils.java
- javatests/com/google/re2j/CharClassTest.java
- javatests/com/google/re2j/MatcherTest.java
- javatests/com/google/re2j/ParserTest.java
- javatests/com/google/re2j/PatternTest.java
- javatests/com/google/re2j/RE2CompileTest.java
- javatests/com/google/re2j/RE2Test.java
- javatests/com/google/re2j/UnicodeTest.java
Changes:
=====================================
RELEASING.md
=====================================
@@ -42,24 +42,37 @@ $ gpg --keyserver keys.openpgp.org --send-keys 90ABCDEF
gpg: sending key 1234567890ABCDEF to hkp://keys.openpgp.org
```
+## Gradle properties
+
+Add the following properties to `$HOME/gradle.properties`:
+
+```
+signing.gnupg.executable=gpg
+signing.gnupg.useLegacyGpg=true
+signing.gnupg.keyName=ABCDEF01
+
+# Not to be confused with your Sonatype login username and password
+ossrhUsername=yourSonatypeToken
+ossrhPassword=yourSonatypeTokenPassword
+```
+
# Making the release
In a shell, change into the RE2/J source code root directory (the one
containing `build.gradle`). Then:
* edit `build.gradle` and set `version` to the name of the next release
- (e.g. "1.8").
+ (e.g. "1.9").
* change the download instructions in `README.md` to reflect the new version
number
* `git commit` the version name change
-* `git tag re2j-<versionName>`, e.g. `git tag re2j-1.8`
+* `git tag re2j-<versionName>`, e.g. `git tag re2j-1.9`
* `git push --tags`
Now you're ready to build and push the release.
```
-./gradlew -Psonatype.username='sonatypeUsername' -Psonatype.password='sonatypeApiKey' \
- clean bintrayUpload
+./gradlew clean uploadArchives
```
Once successful, the new version needs to be published:
=====================================
build.gradle
=====================================
@@ -2,7 +2,7 @@
plugins {
id 'java-library'
id 'wrapper'
- id 'maven-publish'
+ id 'maven'
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
id 'com.github.sherter.google-java-format' version '0.3.2'
id 'net.ltgt.errorprone' version '2.0.2'
@@ -24,7 +24,8 @@ cobertura.coverageFormats = ['html', 'xml']
// The name of the release we're working on. See RELEASING.md for details.
group = "com.google.re2j"
-version = "1.7"
+archivesBaseName = "re2j"
+version = "1.8"
wrapper {
gradleVersion '5.2'
@@ -93,56 +94,60 @@ dependencies {
testRuntime "org.slf4j:slf4j-api:1.7.10"
}
-task sourceJar(type: Jar) {
- baseName 'sources'
-
- from sourceSets.main.allJava
- from sourceSets.gwt.allSource
+task javadocJar(type: Jar) {
+ classifier = 'javadoc'
+ from javadoc
}
-task javadocJar(type: Jar, dependsOn: javadoc) {
- baseName 'javadoc'
-
- from javadoc.destinationDir
+task sourcesJar(type: Jar) {
+ classifier = 'sources'
+ from sourceSets.main.allSource
}
-def appendMavenCentralMetadata(Node node) {
- node.appendNode('name', 'RE2/J')
- node.appendNode('description', 'Linear time regular expressions for Java')
- node.appendNode('url', 'http://github.com/google/re2j')
-
- def license = node.appendNode('licenses').appendNode('license')
- license.appendNode('name', 'Go License')
- license.appendNode('url', 'https://golang.org/LICENSE')
- license.appendNode('distribution', 'repo')
-
- node.appendNode('scm').appendNode('url', 'https://github.com/google/re2j.git')
-
- def developerInfo = node.appendNode('developers').appendNode('developer')
- developerInfo.appendNode('id', 'dev')
- developerInfo.appendNode('name', 'The RE2/J Contributors')
- developerInfo.appendNode('email', 're2j-discuss at googlegroups.com')
+artifacts {
+ archives javadocJar, sourcesJar
}
-publishing {
- publications {
- mavenJava(MavenPublication) {
- from components.java
+uploadArchives {
+ repositories {
+ mavenDeployer {
+ beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
- artifact sourceJar {
- classifier 'sources'
+ repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
+ authentication(userName: findProperty('ossrhUsername') ?: '',
+ password: findProperty('ossrhPassword') ?: '')
}
- artifact javadocJar {
- classifier 'javadoc'
+ snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
+ authentication(userName: findProperty('ossrhUsername') ?: '',
+ password: findProperty('ossrhPassword') ?: '')
}
- groupId 'com.google.re2j'
- artifactId 're2j'
- version project.version
-
- pom.withXml {
- appendMavenCentralMetadata(asNode())
+ pom.project {
+ name 'RE2/J'
+ packaging 'jar'
+ description 'Linear time regular expressions for Java'
+ url 'http://github.com/google/re2j'
+
+ scm {
+ url 'https://github.com/google/re2j.git'
+ }
+
+ licenses {
+ license {
+ name 'Go License'
+ url 'https://golang.org/LICENSE'
+ distribution 'repo'
+ }
+ }
+
+ developers {
+ developer {
+ id 'dev'
+ name 'The RE2/J Contributors'
+ email 're2j-discuss at googlegroups.com'
+ }
+ }
}
}
}
@@ -151,16 +156,7 @@ publishing {
signing {
useGpgCmd()
- sign publishing.publications.mavenJava
-}
-
-nexusPublishing {
- repositories {
- sonatype {
- username = findProperty('sonatype.username')
- password = findProperty('sonatype.password')
- }
- }
+ sign configurations.archives
}
// If Java formatter checks fail, tell the user how to fix them.
=====================================
java/com/google/re2j/Inst.java
=====================================
@@ -50,17 +50,15 @@ final class Inst {
// class.
if (runes.length == 1) {
int r0 = runes[0];
- if (r == r0) {
- return true;
- }
+
+ // If this pattern is case-insensitive, apply Unicode case folding to compare the two runes.
+ // Note that this may result in a case-folding loop when executed on a JVM newer than the version used
+ // to generate Unicode data for re2j, so attempt to reduce the chance of that occurring
+ // by performing case folding on |r0| from the pattern rather than |r| from the input.
if ((arg & RE2.FOLD_CASE) != 0) {
- for (int r1 = Unicode.simpleFold(r0); r1 != r0; r1 = Unicode.simpleFold(r1)) {
- if (r == r1) {
- return true;
- }
- }
+ return Unicode.equalsIgnoreCase(r0, r);
}
- return false;
+ return r == r0;
}
// Peek at the first few pairs.
=====================================
java/com/google/re2j/Matcher.java
=====================================
@@ -7,6 +7,7 @@
package com.google.re2j;
import com.google.re2j.MatcherInput.Encoding;
+import java.io.UnsupportedEncodingException;
import java.util.Map;
/**
@@ -49,6 +50,9 @@ public final class Matcher {
// The number of submatches (groups) in the pattern.
private final int groupCount;
+ // The number of instructions in the pattern.
+ private final int numberOfInstructions;
+
private MatcherInput matcherInput;
// The input length in UTF16 codes.
@@ -76,6 +80,7 @@ public final class Matcher {
groupCount = re2.numberOfCapturingGroups();
groups = new int[2 + 2 * groupCount];
namedGroups = re2.namedGroups;
+ numberOfInstructions = re2.numberOfInstructions();
}
/** Creates a new {@code Matcher} with the given pattern and input. */
@@ -208,6 +213,20 @@ public final class Matcher {
return end(g);
}
+ /**
+ * Returns the program size of this pattern.
+ *
+ * <p>
+ * Similar to the C++ implementation, the program size is a very approximate measure of a regexp's
+ * "cost". Larger numbers are more expensive than smaller numbers.
+ * </p>
+ *
+ * @return the program size of this pattern
+ */
+ public int programSize() {
+ return numberOfInstructions;
+ }
+
/**
* Returns the most recent match.
*
@@ -363,7 +382,11 @@ public final class Matcher {
String substring(int start, int end) {
// UTF_8 is matched in binary mode. So slice the bytes.
if (matcherInput.getEncoding() == Encoding.UTF_8) {
- return new String(matcherInput.asBytes(), start, end - start);
+ try {
+ return new String(matcherInput.asBytes(), start, end - start, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e); // Not possible.
+ }
}
// This is fast for both StringBuilder and String.
=====================================
java/com/google/re2j/Parser.java
=====================================
@@ -28,7 +28,6 @@ class Parser {
private static final String ERR_INTERNAL_ERROR = "regexp/syntax: internal error";
// Parse errors
- private static final String ERR_INVALID_CHAR_CLASS = "invalid character class";
private static final String ERR_INVALID_CHAR_RANGE = "invalid character class range";
private static final String ERR_INVALID_ESCAPE = "invalid escape sequence";
private static final String ERR_INVALID_NAMED_CAPTURE = "invalid named capture";
@@ -1054,21 +1053,22 @@ class Parser {
// support all three as well. EcmaScript 4 uses only the Python form.
//
// In both the open source world (via Code Search) and the
- // Google source tree, (?P<expr>name) is the dominant form,
- // so that's the one we implement. One is enough.
+ // Google source tree, (?P<name>expr) and (?<name>expr) are the
+ // dominant forms of named captures and both are supported.
String s = t.rest();
- if (s.startsWith("(?P<")) {
+ if (s.startsWith("(?P<") || s.startsWith("(?<")) {
// Pull out name.
- int end = s.indexOf('>');
+ int begin = s.charAt(2) == 'P' ? 4 : 3;
+ int end = s.indexOf('>', begin);
if (end < 0) {
throw new PatternSyntaxException(ERR_INVALID_NAMED_CAPTURE, s);
}
- String name = s.substring(4, end); // "name"
+ String name = s.substring(begin, end); // "name"
t.skipString(name);
- t.skip(5); // "(?P<>"
+ t.skip(begin + 1); // "(?P<>" or "(?<>"
if (!isValidCaptureName(name)) {
throw new PatternSyntaxException(
- ERR_INVALID_NAMED_CAPTURE, s.substring(0, end)); // "(?P<name>"
+ ERR_INVALID_NAMED_CAPTURE, s.substring(0, end + 1)); // "(?P<name>" or "(?<name>"
}
// Like ordinary capture, but named.
Regexp re = op(Regexp.Op.LEFT_PAREN);
=====================================
java/com/google/re2j/Pattern.java
=====================================
@@ -300,6 +300,20 @@ public final class Pattern implements Serializable {
return pattern;
}
+ /**
+ * Returns the program size of this pattern.
+ *
+ * <p>
+ * Similar to the C++ implementation, the program size is a very approximate measure of a regexp's
+ * "cost". Larger numbers are more expensive than smaller numbers.
+ * </p>
+ *
+ * @return the program size of this pattern
+ */
+ public int programSize() {
+ return re2.numberOfInstructions();
+ }
+
/**
* Returns the number of capturing groups in this matcher's pattern. Group zero denotes the entire
* pattern and is excluded from this count.
=====================================
java/com/google/re2j/RE2.java
=====================================
@@ -209,6 +209,13 @@ class RE2 {
return numSubexp;
}
+ /**
+ * Returns the number of instructions in this compiled regular expression program.
+ */
+ int numberOfInstructions() {
+ return prog.numInst();
+ }
+
// get() returns a machine to use for matching |this|. It uses |this|'s
// machine cache if possible, to avoid unnecessary allocation.
Machine get() {
=====================================
java/com/google/re2j/Regexp.java
=====================================
@@ -10,6 +10,7 @@
package com.google.re2j;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Map;
/**
@@ -59,7 +60,7 @@ class Regexp {
int min, max; // min, max for REPEAT
int cap; // capturing index, for CAPTURE
String name; // capturing name, for CAPTURE
- Map<String, Integer> namedGroups; // map of group name -> capturing index
+ Map<String, Integer> namedGroups = Collections.emptyMap(); // map of group name -> capturing index
// Do update copy ctor when adding new fields!
Regexp(Op op) {
@@ -85,6 +86,7 @@ class Regexp {
runes = null;
cap = min = max = 0;
name = null;
+ this.namedGroups = Collections.emptyMap();
}
@Override
=====================================
java/com/google/re2j/Unicode.java
=====================================
@@ -122,5 +122,42 @@ class Unicode {
return Characters.toUpperCase(r);
}
+ // equalsIgnoreCase performs case-insensitive equality comparison
+ // on the given runes |r1| and |r2|, with special consideration
+ // for the likely scenario where both runes are ASCII characters.
+ // If non-ASCII, Unicode case folding will be performed on |r1|
+ // to compare it to |r2|.
+ // -1 is interpreted as the end-of-file mark.
+ static boolean equalsIgnoreCase(int r1, int r2) {
+ // Runes already match, or one of them is EOF
+ if (r1 < 0 || r2 < 0 || r1 == r2) {
+ return true;
+ }
+
+ // Fast path for the common case where both runes are ASCII characters.
+ // Coerces both runes to lowercase if applicable.
+ if (r1 <= MAX_ASCII && r2 <= MAX_ASCII) {
+ if ('A' <= r1 && r1 <= 'Z') {
+ r1 |= 0x20;
+ }
+
+ if ('A' <= r2 && r2 <= 'Z') {
+ r2 |= 0x20;
+ }
+
+ return r1 == r2;
+ }
+
+ // Fall back to full Unicode case folding otherwise.
+ // Invariant: r1 must be non-negative
+ for (int r = Unicode.simpleFold(r1); r != r1; r = Unicode.simpleFold(r)) {
+ if (r == r2) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
private Unicode() {} // uninstantiable
}
=====================================
javatests/com/google/re2j/ApiTestUtils.java
=====================================
@@ -159,6 +159,27 @@ public class ApiTestUtils {
assertEquals(count, mj.groupCount());
}
+ // Tests that both RE2 Patterns and Matchers give the same groupCount.
+ public static void testProgramSize(String pattern, int expectedSize) {
+ Pattern p = Pattern.compile(pattern);
+
+ String input = "foo";
+ byte[] inputBytes = getUtf8Bytes(input);
+ Matcher m1 = p.matcher(input);
+ Matcher m2 = p.matcher(inputBytes);
+
+ Truth.assertWithMessage("Pattern(\"%s\") program size", p)
+ .that(p.programSize())
+ .isEqualTo(expectedSize);
+ Truth.assertWithMessage("Matcher(\"%s\", \"%s\") program size", m1.pattern(), input)
+ .that(m1.programSize())
+ .isEqualTo(expectedSize);
+ Truth.assertWithMessage(
+ "Matcher(\"%s\", %s) program size", m2.pattern(), Arrays.toString(inputBytes))
+ .that(m2.programSize())
+ .isEqualTo(expectedSize);
+ }
+
public static void testGroup(String text, String regexp, String[] output) {
// RE2
Pattern p = Pattern.compile(regexp);
=====================================
javatests/com/google/re2j/CharClassTest.java
=====================================
@@ -7,13 +7,14 @@
package com.google.re2j;
import static com.google.re2j.Utils.stringToRunes;
-
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
-
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+ at RunWith(JUnit4.class)
public class CharClassTest {
private static CharClass cc(int... x) {
=====================================
javatests/com/google/re2j/MatcherTest.java
=====================================
@@ -94,8 +94,25 @@ public class MatcherTest {
ApiTestUtils.testReplaceFirst("aab", "a*?", "<$0>", "<>aab");
}
+ @Test
+ public void testProgramSize() {
+ // It is a simple delegation, but still test it.
+ // More test cases are covered in PatternTest#testProgramSize.
+ Pattern pattern = Pattern.compile("go+d");
+ int programSize = pattern.programSize();
+ Truth.assertWithMessage("Pattern program size").that(programSize).isGreaterThan(1);
+ Truth.assertWithMessage("Positive matcher program size")
+ .that(pattern.matcher("good").programSize())
+ .isEqualTo(programSize);
+ Truth.assertWithMessage("Negative matcher program size")
+ .that(pattern.matcher("bad").programSize())
+ .isEqualTo(programSize);
+ }
+
@Test
public void testGroupCount() {
+ // It is a simple delegation, but still test it.
+ // More test cases are covered in PatternTest#testGroupCount.
ApiTestUtils.testGroupCount("(a)(b(c))d?(e)", 4);
}
=====================================
javatests/com/google/re2j/ParserTest.java
=====================================
@@ -21,16 +21,18 @@ import static com.google.re2j.RE2.WAS_DOLLAR;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
+import com.google.common.truth.Truth;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.Map;
-
-import com.google.common.truth.Truth;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
/**
* @author adonovan at google.com (Alan Donovan)
*/
+ at RunWith(JUnit4.class)
public class ParserTest {
private interface RunePredicate {
@@ -232,6 +234,7 @@ public class ParserTest {
// Test named captures
{"(?P<name>a)", "cap{name:lit{a}}"},
+ {"(?<name>a)", "cap{name:lit{a}}"},
// Case-folded literals
{"[Aa]", "litfold{A}"},
@@ -404,6 +407,8 @@ public class ParserTest {
}
b.append('{');
switch (re.op) {
+ default:
+ break;
case END_TEXT:
if ((re.flags & WAS_DOLLAR) == 0) {
b.append("\\z");
@@ -530,12 +535,20 @@ public class ParserTest {
"(?P<name",
"(?P<x y>a)",
"(?P<>a)",
+ "(?<name>a",
+ "(?<name>",
+ "(?<name",
+ "(?<x y>a)",
+ "(?<>a)",
"[a-Z]",
"(?i)[a-Z]",
"a{100000}",
"a{100000,}",
// Group names may not be repeated
"(?P<foo>bar)(?P<foo>baz)",
+ "(?P<foo>bar)(?<foo>baz)",
+ "(?<foo>bar)(?P<foo>baz)",
+ "(?<foo>bar)(?<foo>baz)",
"\\x", // https://github.com/google/re2j/issues/103
"\\xv", // https://github.com/google/re2j/issues/103
};
@@ -550,6 +563,7 @@ public class ParserTest {
"\\Q\\\\\\\\\\E",
"(?:a)",
"(?P<name>a)",
+ "(?<name>a)",
};
private static final String[] ONLY_POSIX = {
@@ -573,7 +587,7 @@ public class ParserTest {
}
}
for (String regexp : ONLY_PERL) {
- Parser.parse(regexp, PERL);
+ Regexp unused = Parser.parse(regexp, PERL);
try {
Regexp re = Parser.parse(regexp, POSIX);
fail("parsing (POSIX) " + regexp + " should have failed, instead got " + dump(re));
@@ -588,7 +602,7 @@ public class ParserTest {
} catch (PatternSyntaxException e) {
/* ok */
}
- Parser.parse(regexp, POSIX);
+ Regexp unused = Parser.parse(regexp, POSIX);
}
}
=====================================
javatests/com/google/re2j/PatternTest.java
=====================================
@@ -164,9 +164,21 @@ public class PatternTest {
ApiTestUtils.testSplit(":", ":a::b", new String[] {"", "a", "", "b"});
}
+ @Test
+ public void testProgramSize() {
+ ApiTestUtils.testProgramSize("", 3);
+ ApiTestUtils.testProgramSize("a", 3);
+ ApiTestUtils.testProgramSize("^", 3);
+ ApiTestUtils.testProgramSize("^$", 4);
+ ApiTestUtils.testProgramSize("a+b", 5);
+ ApiTestUtils.testProgramSize("a+b?", 6);
+ ApiTestUtils.testProgramSize("(a+b)", 7);
+ ApiTestUtils.testProgramSize("a+b.*", 7);
+ ApiTestUtils.testProgramSize("(a+b?)", 8);
+ }
+
@Test
public void testGroupCount() {
- // It is a simple delegation, but still test it.
ApiTestUtils.testGroupCount("(.*)ab(.*)a", 2);
ApiTestUtils.testGroupCount("(.*)(ab)(.*)a", 3);
ApiTestUtils.testGroupCount("(.*)((a)b)(.*)a", 4);
@@ -176,6 +188,8 @@ public class PatternTest {
@Test
public void testNamedGroups() {
+ assertNamedGroupsEquals(ImmutableMap.of("foo", 1), "(?P<foo>\\d{2})");
+ assertNamedGroupsEquals(Collections.<String, Integer>emptyMap(), "\\d{2}");
assertNamedGroupsEquals(Collections.<String, Integer>emptyMap(), "hello");
assertNamedGroupsEquals(Collections.<String, Integer>emptyMap(), "(.*)");
assertNamedGroupsEquals(ImmutableMap.of("any", 1), "(?P<any>.*)");
=====================================
javatests/com/google/re2j/RE2CompileTest.java
=====================================
@@ -67,7 +67,7 @@ public class RE2CompileTest {
@Test
public void testCompile() {
try {
- RE2.compile(input);
+ RE2 unused = RE2.compile(input);
if (expectedError != null) {
fail("RE2.compile(" + input + ") was successful, expected " + expectedError);
}
=====================================
javatests/com/google/re2j/RE2Test.java
=====================================
@@ -9,13 +9,16 @@
package com.google.re2j;
-import java.util.Arrays;
-import org.junit.Test;
-
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import java.util.Arrays;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
/** Tests of RE2 API. */
+ at RunWith(JUnit4.class)
public class RE2Test {
@Test
public void testFullMatch() {
=====================================
javatests/com/google/re2j/UnicodeTest.java
=====================================
@@ -6,10 +6,15 @@
*/
package com.google.re2j;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
+import java.util.ArrayList;
+import java.util.List;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+ at RunWith(JUnit4.class)
public class UnicodeTest {
@Test
@@ -29,6 +34,56 @@ public class UnicodeTest {
}
}
+ @Test
+ public void testEqualsIgnoreCase() {
+ List<EqualsIgnoreCaseTest> testCases = new ArrayList<EqualsIgnoreCaseTest>();
+
+ for (int r = 'a'; r <= 'z'; r++) {
+ int u = r - ('a' - 'A');
+ testCases.add(new EqualsIgnoreCaseTest(r, r, true));
+ testCases.add(new EqualsIgnoreCaseTest(u, u, true));
+ testCases.add(new EqualsIgnoreCaseTest(r, u, true));
+ testCases.add(new EqualsIgnoreCaseTest(u, r, true));
+ }
+
+ testCases.add(new EqualsIgnoreCaseTest('{', '{', true));
+ testCases.add(new EqualsIgnoreCaseTest('é', 'É', true));
+ testCases.add(new EqualsIgnoreCaseTest('Ú', 'ú', true));
+ testCases.add(new EqualsIgnoreCaseTest('\u212A', 'K', true));
+ testCases.add(new EqualsIgnoreCaseTest('\u212A', 'k', true));
+
+ testCases.add(new EqualsIgnoreCaseTest('\u212A', 'a', false));
+ testCases.add(new EqualsIgnoreCaseTest('ü', 'ű', false));
+ testCases.add(new EqualsIgnoreCaseTest('b', 'k', false));
+ testCases.add(new EqualsIgnoreCaseTest('C', 'x', false));
+ testCases.add(new EqualsIgnoreCaseTest('/', '_', false));
+ testCases.add(new EqualsIgnoreCaseTest('d', ')', false));
+ testCases.add(new EqualsIgnoreCaseTest('@', '`', false));
+
+ for (EqualsIgnoreCaseTest testCase : testCases) {
+ boolean equals = Unicode.equalsIgnoreCase(testCase.r1, testCase.r2);
+
+ if (testCase.shouldMatch) {
+ assertTrue((char) testCase.r1 + " should be equal to " + (char) testCase.r2, equals);
+ } else {
+ assertFalse((char) testCase.r1 + " should not be equal to " + (char) testCase.r2, equals);
+ }
+ }
+ }
+
+ // EqualsIgnoreCaseTest wraps test case parameters for testEqualsIgnoreCase().
+ private static class EqualsIgnoreCaseTest {
+ private final int r1;
+ private final int r2;
+ private final boolean shouldMatch;
+
+ public EqualsIgnoreCaseTest(int r1, int r2, boolean shouldMatch) {
+ this.r1 = r1;
+ this.r2 = r2;
+ this.shouldMatch = shouldMatch;
+ }
+ }
+
// TODO(adonovan): tests for:
//
// boolean isUpper(int r);
View it on GitLab: https://salsa.debian.org/java-team/re2j/-/commit/620457bb97aa26fcf0f45a14faa50916b09cb1f6
--
View it on GitLab: https://salsa.debian.org/java-team/re2j/-/commit/620457bb97aa26fcf0f45a14faa50916b09cb1f6
You're receiving this email because of your account on salsa.debian.org. Manage all notifications: https://salsa.debian.org/-/profile/notifications | Help: https://salsa.debian.org/help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20261113/323bdd3c/attachment.htm>
More information about the pkg-java-commits
mailing list