Repository: lucy
Updated Branches:
  refs/heads/master f5916a4e0 -> 6cc97ecec


Test Go bindings for Lexicon.

Use SegLexicon to test out Lexicon.


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

Branch: refs/heads/master
Commit: 932c211412d89078a5ebc2400fd36540f534f0ba
Parents: f5916a4
Author: Marvin Humphrey <[email protected]>
Authored: Thu Dec 3 16:06:44 2015 -0800
Committer: Marvin Humphrey <[email protected]>
Committed: Thu Dec 10 16:01:48 2015 -0800

----------------------------------------------------------------------
 go/lucy/index_test.go | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/932c2114/go/lucy/index_test.go
----------------------------------------------------------------------
diff --git a/go/lucy/index_test.go b/go/lucy/index_test.go
index e7c93a9..2df680f 100644
--- a/go/lucy/index_test.go
+++ b/go/lucy/index_test.go
@@ -642,3 +642,36 @@ func TestInverterMisc(t *testing.T) {
                t.Errorf("GetInversion after iterator exhausted: %v", got)
        }
 }
+
+// Use SegLexicon to air out the Lexicon interface.
+func TestLexiconBasics(t *testing.T) {
+       folder := createTestIndex("a", "b", "c")
+       searcher, _ := OpenIndexSearcher(folder)
+       segReaders := searcher.GetReader().SegReaders()
+       lexReader := 
segReaders[0].(SegReader).Obtain("Lucy::Index::LexiconReader").(LexiconReader)
+       segLex := lexReader.Lexicon("content", nil).(Lexicon)
+       if field := segLex.getField(); field != "content" {
+               t.Errorf("getField: %s", field)
+       }
+       segLex.Next()
+       if got := segLex.GetTerm(); got != "a" {
+               t.Errorf("GetTerm: %v", got)
+       }
+       if docFreq := segLex.docFreq(); docFreq != 1 {
+               t.Errorf("docFreq: %d", docFreq)
+       }
+       if !segLex.Next() || !segLex.Next() {
+               t.Errorf("Iterate")
+       }
+       if segLex.Next() {
+               t.Errorf("Iteration should be finished")
+       }
+       segLex.Seek("b")
+       if got := segLex.GetTerm(); got != "b" {
+               t.Errorf("Seek: %v", got)
+       }
+       segLex.Reset()
+       if !segLex.Next() {
+               t.Errorf("Next after Reset")
+       }
+}

Reply via email to