From 607c87a66bff8b61654fa8ad7c28d271ed0f40e0 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Sun, 12 Apr 2015 13:29:01 +0000 Subject: [PATCH] LUCENE-5879: fix finite case of Automata.makeBinaryIterval, improve tests git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1673009 13f79535-47bb-0310-9956-ffa450edef68 --- .../lucene/util/automaton/Automata.java | 70 ++++++-- .../lucene/util/automaton/TestAutomaton.java | 160 +++++++++++++++--- 2 files changed, 199 insertions(+), 31 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/util/automaton/Automata.java b/lucene/core/src/java/org/apache/lucene/util/automaton/Automata.java index 3bcd31945c7..294700b8499 100644 --- a/lucene/core/src/java/org/apache/lucene/util/automaton/Automata.java +++ b/lucene/core/src/java/org/apache/lucene/util/automaton/Automata.java @@ -32,6 +32,7 @@ package org.apache.lucene.util.automaton; import java.util.*; import org.apache.lucene.util.BytesRef; +import org.apache.lucene.util.StringHelper; /** * Construction of basic automata. @@ -216,6 +217,16 @@ final public class Automata { return s; } + private static boolean suffixIsZeros(BytesRef br, int len) { + for(int i=len;i min.length; + + // bar -> bar\0+ + if (maxInclusive == false) { + maxLength--; + } + + if (maxLength == min.length) { + if (minInclusive == false) { + return makeEmpty(); + } else { + return makeBinary(min); + } + } + + Automaton a = new Automaton(); + int lastState = a.createState(); + for (int i=0;i