Test HitQueue Go bindings.

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

Branch: refs/heads/master
Commit: 8c1e020e239e03446196bbd810a7f5c0c9f424c4
Parents: 295662d
Author: Marvin Humphrey <[email protected]>
Authored: Thu Sep 10 20:52:41 2015 -0700
Committer: Marvin Humphrey <[email protected]>
Committed: Tue Sep 15 15:54:50 2015 -0700

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


http://git-wip-us.apache.org/repos/asf/lucy/blob/8c1e020e/go/lucy/search_test.go
----------------------------------------------------------------------
diff --git a/go/lucy/search_test.go b/go/lucy/search_test.go
index 6e40670..1f34df9 100644
--- a/go/lucy/search_test.go
+++ b/go/lucy/search_test.go
@@ -396,3 +396,31 @@ func TestSortSpecBasics(t *testing.T) {
                t.Errorf("Failed round-trip serializetion of SortSpec")
        }
 }
+
+func TestHitQueueBasics(t *testing.T) {
+       hitQ := NewHitQueue(nil, nil, 1)
+       fortyTwo := NewMatchDoc(42, 1.0, nil)
+       fortyThree := NewMatchDoc(43, 1.0, nil)
+       if !hitQ.LessThan(fortyThree, fortyTwo) {
+               t.Error("LessThan")
+       }
+       if !hitQ.Insert(fortyTwo) {
+               t.Error("Insert")
+       }
+       if hitQ.GetSize() != 1 {
+               t.Error("GetSize")
+       }
+       if bumped := hitQ.Jostle(fortyThree); bumped.(MatchDoc).GetDocID() != 
43 {
+               t.Error("Jostle")
+       }
+       if peeked := hitQ.Peek(); peeked.(MatchDoc).GetDocID() != 42 {
+               t.Error("Peek")
+       }
+       if popped := hitQ.Pop(); popped.(MatchDoc).GetDocID() != 42 {
+               t.Error("Pop")
+       }
+       hitQ.Insert(fortyTwo)
+       if got := hitQ.PopAll(); got[0].(MatchDoc).GetDocID() != 42 {
+               t.Error("PopAll")
+       }
+}

Reply via email to