Repository: lucy Updated Branches: refs/heads/master 15d4564a2 -> 91d34ea4c
Test Hits Go bindings. Project: http://git-wip-us.apache.org/repos/asf/lucy/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/be4b75da Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/be4b75da Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/be4b75da Branch: refs/heads/master Commit: be4b75da3b26757534fc82e00e061b983b38a8d6 Parents: d1f3764 Author: Marvin Humphrey <[email protected]> Authored: Fri Sep 11 17:18:00 2015 -0700 Committer: Marvin Humphrey <[email protected]> Committed: Tue Sep 15 15:54:50 2015 -0700 ---------------------------------------------------------------------- go/lucy/search_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy/blob/be4b75da/go/lucy/search_test.go ---------------------------------------------------------------------- diff --git a/go/lucy/search_test.go b/go/lucy/search_test.go index b082c51..02881d2 100644 --- a/go/lucy/search_test.go +++ b/go/lucy/search_test.go @@ -359,6 +359,29 @@ type simpleTestDoc struct { Content string } +func TestHitsBasics(t *testing.T) { + index := createTestIndex("a", "b") + searcher, _ := OpenIndexSearcher(index) + topDocs := searcher.TopDocs(NewTermQuery("content", "a"), 10, nil) + hits := NewHits(searcher, topDocs, 0) + if got := hits.TotalHits(); got != topDocs.GetTotalHits() { + t.Errorf("TotalHits is off: %d", got) + } + var doc simpleTestDoc + if !hits.Next(&doc) { + t.Error("Hits.Next") + } + if doc.Content != "a" { + t.Errorf("Bad doc content after Next: %s", doc.Content) + } + if hits.Next(&doc) { + t.Error("Hits iterator should be exhausted"); + } + if err := hits.Error(); err != nil { + t.Error("Hits.Error() not nil: %v", err) + } +} + func TestSortSpecBasics(t *testing.T) { folder := NewRAMFolder("") schema := NewSchema()
