LUCENE-6365: fix test to not add duplicate strings

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1689404 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2015-07-06 14:03:46 +00:00
parent 4d8127f437
commit f0b550a092
2 changed files with 8 additions and 4 deletions

View File

@ -33,6 +33,9 @@ import java.util.BitSet;
* <p>Be aware that the iteration order is implementation dependent * <p>Be aware that the iteration order is implementation dependent
* and may change across releases. * and may change across releases.
* *
* <p>If the automaton is not determinized then it's possible this iterator
* will return duplicates.
*
* @lucene.experimental * @lucene.experimental
*/ */
public class FiniteStringsIterator { public class FiniteStringsIterator {

View File

@ -47,13 +47,14 @@ public class FiniteStringsIteratorTest extends LuceneTestCase {
IntsRefBuilder scratch = new IntsRefBuilder(); IntsRefBuilder scratch = new IntsRefBuilder();
for(int i=0;i<numStrings;i++) { for(int i=0;i<numStrings;i++) {
String s = TestUtil.randomSimpleString(random(), 1, 200); String s = TestUtil.randomSimpleString(random(), 1, 200);
automata.add(Automata.makeString(s));
Util.toUTF32(s.toCharArray(), 0, s.length(), scratch); Util.toUTF32(s.toCharArray(), 0, s.length(), scratch);
strings.add(scratch.toIntsRef()); if (strings.add(scratch.toIntsRef())) {
automata.add(Automata.makeString(s));
if (VERBOSE) { if (VERBOSE) {
System.out.println(" add string=" + s); System.out.println(" add string=" + s);
} }
} }
}
// TODO: we could sometimes use // TODO: we could sometimes use
// DaciukMihovAutomatonBuilder here // DaciukMihovAutomatonBuilder here