mirror of https://github.com/apache/lucene.git
SOLR-2762: Adding more unit tests, but can't reproduce or figure out where off-by-one could happen here.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1171066 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
318911200d
commit
e83e9dfbf3
|
@ -43,6 +43,12 @@ public class FSTLookupTest extends LuceneTestCase {
|
||||||
|
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
|
lookup = new FSTLookup();
|
||||||
|
lookup.build(new TermFreqArrayIterator(evalKeys()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private TermFreq[] evalKeys() {
|
||||||
final TermFreq[] keys = new TermFreq[] {
|
final TermFreq[] keys = new TermFreq[] {
|
||||||
tf("one", 0.5f),
|
tf("one", 0.5f),
|
||||||
tf("oneness", 1),
|
tf("oneness", 1),
|
||||||
|
@ -61,9 +67,7 @@ public class FSTLookupTest extends LuceneTestCase {
|
||||||
tf("fourty", 1),
|
tf("fourty", 1),
|
||||||
tf("xo", 1),
|
tf("xo", 1),
|
||||||
};
|
};
|
||||||
|
return keys;
|
||||||
lookup = new FSTLookup();
|
|
||||||
lookup.build(new TermFreqArrayIterator(keys));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExactMatchHighPriority() throws Exception {
|
public void testExactMatchHighPriority() throws Exception {
|
||||||
|
@ -76,6 +80,31 @@ public class FSTLookupTest extends LuceneTestCase {
|
||||||
"oneness/1.0");
|
"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 {
|
public void testMiss() throws Exception {
|
||||||
assertMatchEquals(lookup.lookup("xyz", true, 1));
|
assertMatchEquals(lookup.lookup("xyz", true, 1));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue