lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [07/15] lucy git commit: Test Go bindings for DocVector.
Date Sat, 07 Nov 2015 02:48:56 GMT
Test Go bindings for DocVector.


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

Branch: refs/heads/master
Commit: 54733ad5b75cf7bb1ca75081f4a97ec12b1bd7f6
Parents: a8bb3b5
Author: Marvin Humphrey <marvin@rectangular.com>
Authored: Sat Oct 31 17:31:37 2015 -0700
Committer: Marvin Humphrey <marvin@rectangular.com>
Committed: Sun Nov 1 10:00:35 2015 -0800

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


http://git-wip-us.apache.org/repos/asf/lucy/blob/54733ad5/go/lucy/index_test.go
----------------------------------------------------------------------
diff --git a/go/lucy/index_test.go b/go/lucy/index_test.go
index c4e70f9..bf7fd67 100644
--- a/go/lucy/index_test.go
+++ b/go/lucy/index_test.go
@@ -324,6 +324,37 @@ func TestTermVectorMisc(t *testing.T) {
 	}
 }
 
+func TestDocVectorMisc(t *testing.T) {
+	schema := NewSchema()
+	spec := NewFullTextType(NewStandardTokenizer())
+	spec.SetHighlightable(true)
+	schema.SpecField("content", spec)
+	folder := NewRAMFolder("")
+	indexer, _ := OpenIndexer(&OpenIndexerArgs{Index: folder, Schema: schema, Create: true})
+	indexer.AddDoc(&testDoc{Content: "foo bar baz"})
+	indexer.Commit()
+	searcher, _ := OpenIndexSearcher(folder)
+	dv := searcher.FetchDocVec(1)
+	fieldBuf := dv.FieldBuf("content");
+	if fieldBuf == nil {
+		t.Errorf("FieldBuf returned nil")
+	}
+	dv.AddFieldBuf("content", fieldBuf)
+	if got := dv.TermVector("content", "bar"); got == nil {
+		t.Errorf("TermVector returned nil")
+	}
+
+	out, _ := folder.OpenOut("dump")
+	dv.Serialize(out)
+	out.Close()
+	in, _ := folder.OpenIn("dump")
+	dupe := clownfish.GetClass(dv).MakeObj().(DocVector).Deserialize(in)
+	in.Close()
+	if _, ok := dupe.(DocVector); !ok {
+		t.Errorf("Serialize/Deserialize")
+	}
+}
+
 func TestSnapshotMisc(t *testing.T) {
 	var err error
 	snapshot := NewSnapshot()


Mime
View raw message