Also backport this one? Mike McCandless
http://blog.mikemccandless.com On Thu, Sep 15, 2011 at 8:07 AM, <[email protected]> wrote: > Author: dweiss > Date: Thu Sep 15 12:07:51 2011 > New Revision: 1171066 > > URL: http://svn.apache.org/viewvc?rev=1171066&view=rev > Log: > SOLR-2762: Adding more unit tests, but can't reproduce or figure out where > off-by-one could happen here. > > Modified: > > lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/fst/FSTLookupTest.java > > Modified: > lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/fst/FSTLookupTest.java > URL: > http://svn.apache.org/viewvc/lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/fst/FSTLookupTest.java?rev=1171066&r1=1171065&r2=1171066&view=diff > ============================================================================== > --- > lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/fst/FSTLookupTest.java > (original) > +++ > lucene/dev/trunk/modules/suggest/src/test/org/apache/lucene/search/suggest/fst/FSTLookupTest.java > Thu Sep 15 12:07:51 2011 > @@ -43,6 +43,12 @@ public class FSTLookupTest extends Lucen > > public void setUp() throws Exception { > super.setUp(); > + > + lookup = new FSTLookup(); > + lookup.build(new TermFreqArrayIterator(evalKeys())); > + } > + > + private TermFreq[] evalKeys() { > final TermFreq[] keys = new TermFreq[] { > tf("one", 0.5f), > tf("oneness", 1), > @@ -61,9 +67,7 @@ public class FSTLookupTest extends Lucen > tf("fourty", 1), > tf("xo", 1), > }; > - > - lookup = new FSTLookup(); > - lookup.build(new TermFreqArrayIterator(keys)); > + return keys; > } > > public void testExactMatchHighPriority() throws Exception { > @@ -76,6 +80,31 @@ public class FSTLookupTest extends Lucen > "oneness/1.0"); > } > > + public void testRequestedCount() throws Exception { > + // 'one' is promoted after collecting two higher ranking results. > + assertMatchEquals(lookup.lookup("one", true, 2), > + "one/0.0", > + "oneness/1.0"); > + > + // 'one' is at the top after collecting all alphabetical results. > + assertMatchEquals(lookup.lookup("one", false, 2), > + "one/0.0", > + "oneness/1.0"); > + > + lookup = new FSTLookup(10, false); > + lookup.build(new TermFreqArrayIterator(evalKeys())); > + > + // 'one' is not promoted after collecting two higher ranking results. > + assertMatchEquals(lookup.lookup("one", true, 2), > + "oneness/1.0", > + "onerous/1.0"); > + > + // 'one' is at the top after collecting all alphabetical results. > + assertMatchEquals(lookup.lookup("one", false, 2), > + "one/0.0", > + "oneness/1.0"); > + } > + > public void testMiss() throws Exception { > assertMatchEquals(lookup.lookup("xyz", true, 1)); > } > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
