Test Go bindings for PostingList.
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/a693aa1d Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/a693aa1d Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/a693aa1d Branch: refs/heads/master Commit: a693aa1decaff2b4e33eaacc180cf95b680d8317 Parents: 932c211 Author: Marvin Humphrey <[email protected]> Authored: Thu Dec 3 17:37:07 2015 -0800 Committer: Marvin Humphrey <[email protected]> Committed: Thu Dec 10 16:01:49 2015 -0800 ---------------------------------------------------------------------- go/lucy/index_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy/blob/a693aa1d/go/lucy/index_test.go ---------------------------------------------------------------------- diff --git a/go/lucy/index_test.go b/go/lucy/index_test.go index 2df680f..5affb0d 100644 --- a/go/lucy/index_test.go +++ b/go/lucy/index_test.go @@ -675,3 +675,27 @@ func TestLexiconBasics(t *testing.T) { t.Errorf("Next after Reset") } } + +func TestPostingListBasics(t *testing.T) { + folder := createTestIndex("c", "b b b", "a", "b",) + searcher, _ := OpenIndexSearcher(folder) + segReaders := searcher.GetReader().SegReaders() + pListReader := segReaders[0].(SegReader).Obtain("Lucy::Index::PostingListReader").(PostingListReader) + pList := pListReader.PostingList("content", nil) + pList.Seek("b") + if docFreq := pList.GetDocFreq(); docFreq != 2 { + t.Errorf("GetDocFreq: %d", docFreq) + } + if got := pList.Next(); got != 2 { + t.Errorf("Next: %d", got) + } + if docID := pList.GetDocID(); docID != 2 { + t.Errorf("GetDocID: %d", docID) + } + if got := pList.Next(); got != 4 { + t.Errorf("Next (second iter): %d", got) + } + if got := pList.Next(); got != 0 { + t.Error("Next (done): %d", got) + } +}
