Test Go bindings for Inversion.
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/4f7227e7 Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/4f7227e7 Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/4f7227e7 Branch: refs/heads/master Commit: 4f7227e74b62e070dd1aae7e9c86b0cf388762dc Parents: 7dd69a6 Author: Marvin Humphrey <[email protected]> Authored: Tue Oct 6 15:59:13 2015 -0700 Committer: Marvin Humphrey <[email protected]> Committed: Tue Oct 6 18:44:17 2015 -0700 ---------------------------------------------------------------------- go/build.go | 5 +++++ go/lucy/analysis_test.go | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy/blob/4f7227e7/go/build.go ---------------------------------------------------------------------- diff --git a/go/build.go b/go/build.go index e250aeb..b265c2b 100644 --- a/go/build.go +++ b/go/build.go @@ -136,6 +136,11 @@ func runCFC() { } func specClasses(parcel *cfc.Parcel) { + tokenBinding := cfc.NewGoClass(parcel, "Lucy::Analysis::Token") + tokenBinding.SpecMethod("", "SetText(string)") + tokenBinding.SpecMethod("", "GetText() string") + tokenBinding.Register() + indexerBinding := cfc.NewGoClass(parcel, "Lucy::Index::Indexer") indexerBinding.SpecMethod("", "Close() error") indexerBinding.SpecMethod("Add_Doc", "AddDoc(doc interface{}) error") http://git-wip-us.apache.org/repos/asf/lucy/blob/4f7227e7/go/lucy/analysis_test.go ---------------------------------------------------------------------- diff --git a/go/lucy/analysis_test.go b/go/lucy/analysis_test.go index 2ae7a34..300ae4c 100644 --- a/go/lucy/analysis_test.go +++ b/go/lucy/analysis_test.go @@ -38,6 +38,31 @@ func TestTokenBasics(t *testing.T) { token.GetLen() } +func TestInversionBasics(t *testing.T) { + inv := NewInversion(nil) + inv.Append(NewToken("foo")) + inv.Append(NewToken("bar")) + inv.Append(NewToken("baz")) + if size := inv.GetSize(); size != 3 { + t.Errorf("Unexpected size: %d", size) + } + + if got := inv.Next().GetText(); got != "foo" { + t.Errorf("Next yielded %s", got) + } + + inv.Reset() + if got := inv.Next().GetText(); got != "foo" { + t.Errorf("Next after Reset yielded %s", got) + } + + inv.Reset() + inv.Invert() + if got := inv.Next().GetText(); got != "bar" { + t.Errorf("Next after Invert yielded %s", got) + } +} + func TestRegexTokenizerSplit(t *testing.T) { tokenizer := NewRegexTokenizer("\\S+") var expected []interface{} = []interface{}{"foo", "bar", "baz"}
