Test RangeMatcher Go bindings.

Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/888c0802
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/888c0802
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/888c0802

Branch: refs/heads/master
Commit: 888c080217fbaa7117ec1c41e989f7d775b476d3
Parents: ab62643
Author: Marvin Humphrey <[email protected]>
Authored: Fri Sep 11 18:37:08 2015 -0700
Committer: Marvin Humphrey <[email protected]>
Committed: Tue Sep 15 15:54:51 2015 -0700

----------------------------------------------------------------------
 go/lucy/lucy_test.go   |  1 +
 go/lucy/search_test.go | 25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/888c0802/go/lucy/lucy_test.go
----------------------------------------------------------------------
diff --git a/go/lucy/lucy_test.go b/go/lucy/lucy_test.go
index c0c743e..8f11a3d 100644
--- a/go/lucy/lucy_test.go
+++ b/go/lucy/lucy_test.go
@@ -59,6 +59,7 @@ func createTestSchema() Schema {
        analyzer := NewStandardTokenizer()
        fieldType := NewFullTextType(analyzer)
        fieldType.SetHighlightable(true)
+       fieldType.SetSortable(true)
        schema.SpecField("content", fieldType)
        return schema
 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/888c0802/go/lucy/search_test.go
----------------------------------------------------------------------
diff --git a/go/lucy/search_test.go b/go/lucy/search_test.go
index d227e5f..6d0c42d 100644
--- a/go/lucy/search_test.go
+++ b/go/lucy/search_test.go
@@ -359,6 +359,31 @@ func TestNoMatchMatcherBasics(t *testing.T) {
        }
 }
 
+func TestRangeMatcherBasics(t *testing.T) {
+       index := createTestIndex("d", "c", "b", "a", "a", "a", "a")
+       searcher, _ := OpenIndexSearcher(index)
+       segReaders := searcher.GetReader().SegReaders()
+       segReader := segReaders[0].(SegReader)
+       sortReader := segReader.Obtain("Lucy::Index::SortReader").(SortReader)
+       sortCache := sortReader.FetchSortCache("content")
+       matcher := NewRangeMatcher(0, 0, sortCache, segReader.DocMax())
+       if docID := matcher.Next(); docID != 4 {
+               t.Errorf("Next: %d", docID)
+       }
+       if docID := matcher.GetDocID(); docID != 4 {
+               t.Errorf("GetDocID: %d", docID)
+       }
+       if score := matcher.Score(); score != 0.0 {
+               t.Errorf("Score: %f", score)
+       }
+       if docID := matcher.Advance(7); docID != 7 {
+               t.Errorf("Advance: %d", docID)
+       }
+       if docID := matcher.Next(); docID != 0 {
+               t.Errorf("Matcher should be exhausted: %d", docID)
+       }
+}
+
 func TestTopDocsBasics(t *testing.T) {
        matchDocs := []MatchDoc{
                NewMatchDoc(42, 2.0, nil),

Reply via email to