You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2019/12/09 07:32:20 UTC
[lucene-solr] branch master updated: LUCENE-9085: Fix assertion in
CharacterUtils (#1067)
This is an automated email from the ASF dual-hosted git repository.
jpountz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/master by this push:
new 7900712 LUCENE-9085: Fix assertion in CharacterUtils (#1067)
7900712 is described below
commit 79007128e3f1d5dfe51a9575473a4ab757c557f9
Author: Daiki Tsuzuku <45...@users.noreply.github.com>
AuthorDate: Mon Dec 9 16:32:07 2019 +0900
LUCENE-9085: Fix assertion in CharacterUtils (#1067)
---
.../src/java/org/apache/lucene/analysis/CharacterUtils.java | 4 ++--
.../test/org/apache/lucene/analysis/TestCharacterUtils.java | 11 +++++++++++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/lucene/core/src/java/org/apache/lucene/analysis/CharacterUtils.java b/lucene/core/src/java/org/apache/lucene/analysis/CharacterUtils.java
index e2cc47f..9ed077c 100644
--- a/lucene/core/src/java/org/apache/lucene/analysis/CharacterUtils.java
+++ b/lucene/core/src/java/org/apache/lucene/analysis/CharacterUtils.java
@@ -53,7 +53,7 @@ public final class CharacterUtils {
*/
public static void toLowerCase(final char[] buffer, final int offset, final int limit) {
assert buffer.length >= limit;
- assert offset <=0 && offset <= buffer.length;
+ assert 0 <= offset && offset <= buffer.length;
for (int i = offset; i < limit;) {
i += Character.toChars(
Character.toLowerCase(
@@ -70,7 +70,7 @@ public final class CharacterUtils {
*/
public static void toUpperCase(final char[] buffer, final int offset, final int limit) {
assert buffer.length >= limit;
- assert offset <=0 && offset <= buffer.length;
+ assert 0 <= offset && offset <= buffer.length;
for (int i = offset; i < limit;) {
i += Character.toChars(
Character.toUpperCase(
diff --git a/lucene/core/src/test/org/apache/lucene/analysis/TestCharacterUtils.java b/lucene/core/src/test/org/apache/lucene/analysis/TestCharacterUtils.java
index 438e5e3..d6bebca 100644
--- a/lucene/core/src/test/org/apache/lucene/analysis/TestCharacterUtils.java
+++ b/lucene/core/src/test/org/apache/lucene/analysis/TestCharacterUtils.java
@@ -32,6 +32,17 @@ import org.junit.Test;
*/
public class TestCharacterUtils extends LuceneTestCase {
+ public void testLowerUpper() throws IOException {
+ Reader reader = new StringReader("ABc");
+ CharacterBuffer buffer = CharacterUtils.newCharacterBuffer(3);
+ assertTrue(CharacterUtils.fill(buffer, reader));
+ assertEquals(3, buffer.getLength());
+ CharacterUtils.toLowerCase(buffer.getBuffer(), 1, 3);
+ assertEquals("Abc", new String(buffer.getBuffer()));
+ CharacterUtils.toUpperCase(buffer.getBuffer(), 1, 3);
+ assertEquals("ABC", new String(buffer.getBuffer()));
+ }
+
public void testConversions() {
final char[] orig = TestUtil.randomUnicodeString(random(), 100).toCharArray();
final int[] buf = new int[orig.length];