From 5ec072be9da05b8c4cb959fe475de2a5bde2136b Mon Sep 17 00:00:00 2001 From: Mike McCandless Date: Wed, 3 Aug 2016 14:30:44 -0400 Subject: [PATCH] add test case --- .../lucene/util/TestMSBRadixSorter.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/lucene/core/src/test/org/apache/lucene/util/TestMSBRadixSorter.java b/lucene/core/src/test/org/apache/lucene/util/TestMSBRadixSorter.java index c496ff8b3cf..52eb494711a 100644 --- a/lucene/core/src/test/org/apache/lucene/util/TestMSBRadixSorter.java +++ b/lucene/core/src/test/org/apache/lucene/util/TestMSBRadixSorter.java @@ -17,6 +17,8 @@ package org.apache.lucene.util; import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; public class TestMSBRadixSorter extends LuceneTestCase { @@ -117,4 +119,67 @@ public class TestMSBRadixSorter extends LuceneTestCase { testRandom(TestUtil.nextInt(random(), 1, 30), 2); } } + + public void testRandom2() { + // how large our alphabet is + int letterCount = TestUtil.nextInt(random(), 2, 10); + + // how many substring fragments to use + int substringCount = TestUtil.nextInt(random(), 2, 10); + Set substringsSet = new HashSet<>(); + + // how many strings to make + int stringCount = atLeast(10000); + + //System.out.println("letterCount=" + letterCount + " substringCount=" + substringCount + " stringCount=" + stringCount); + while(substringsSet.size() < substringCount) { + int length = TestUtil.nextInt(random(), 2, 10); + byte[] bytes = new byte[length]; + for(int i=0;i stringsSet = new HashSet<>(); + int iters = 0; + while (stringsSet.size() < stringCount && iters < stringCount*5) { + int count = TestUtil.nextInt(random(), 1, 5); + BytesRefBuilder b = new BytesRefBuilder(); + for(int i=0;i= v) { + b.append(substrings[j]); + break; + } + } + } + BytesRef br = b.toBytesRef(); + stringsSet.add(br); + //System.out.println("add string count=" + stringsSet.size() + ": " + br); + iters++; + } + + test(stringsSet.toArray(new BytesRef[stringsSet.size()]), stringsSet.size()); + } }