lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [13/14] lucy git commit: Test Go bindings for MatchDoc.
Date Mon, 28 Sep 2015 19:52:29 GMT
Test Go bindings for MatchDoc.


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

Branch: refs/heads/master
Commit: 2aa24c199b204a254705caf94bf8013011f98699
Parents: faab39e
Author: Marvin Humphrey <marvin@rectangular.com>
Authored: Tue Sep 15 16:50:57 2015 -0700
Committer: Marvin Humphrey <marvin@rectangular.com>
Committed: Tue Sep 15 16:50:57 2015 -0700

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


http://git-wip-us.apache.org/repos/asf/lucy/blob/2aa24c19/go/lucy/search_test.go
----------------------------------------------------------------------
diff --git a/go/lucy/search_test.go b/go/lucy/search_test.go
index 00d68c1..b281477 100644
--- a/go/lucy/search_test.go
+++ b/go/lucy/search_test.go
@@ -622,3 +622,34 @@ func TestIndexSearcherTopDocs(t *testing.T) {
 		t.Errorf("TopDocs expected 2, got %d", docID)
 	}
 }
+
+func TestMatchDocBasics(t *testing.T) {
+	matchDoc := NewMatchDoc(0, 1.0, nil)
+	matchDoc.SetDocID(42)
+	if got := matchDoc.GetDocID(); got != 42 {
+		t.Errorf("Set/GetDocID: %d", got)
+	}
+	matchDoc.SetScore(1.5)
+	if got := matchDoc.GetScore(); got != 1.5 {
+		t.Errorf("Set/GetScore: %f", got)
+	}
+	values := []interface{}{"foo", int64(42)}
+	matchDoc.SetValues(values)
+	if got := matchDoc.GetValues(); !reflect.DeepEqual(got, values) {
+		t.Error("Get/SetValues")
+	}
+}
+
+func TestMatchDocSerialization(t *testing.T) {
+	values := []interface{}{"foo", int64(42)}
+	matchDoc := NewMatchDoc(100, 1.5, values)
+	folder := NewRAMFolder("")
+	outstream := folder.OpenOut("foo")
+	matchDoc.Serialize(outstream)
+	outstream.Close()
+	inStream := folder.OpenIn("foo")
+	dupe := clownfish.GetClass(matchDoc).MakeObj().(MatchDoc).Deserialize(inStream)
+	if got := dupe.GetValues(); !reflect.DeepEqual(got, values) {
+		t.Errorf("Failed round-trip serializetion of MatchDoc")
+	}
+}


Mime
View raw message