Skip to content

Commit

Permalink
Added test to make sure we can still find stuff in a pseudo endless s…
Browse files Browse the repository at this point in the history
…egment
  • Loading branch information
seppestas committed Apr 27, 2015
1 parent 9e5b9a6 commit c2e6f26
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,50 @@ func TestFindingSingleElement(t *testing.T) {
}
}

func TestFindingElementSizeZeroRange(t *testing.T) {
tree := new(Tree)
test := "hello, world"
tree.Push(1, 1, test)
tree.BuildTree()

results, err := tree.QueryIndex(1)
if err != nil {
queryFailed(t, err)
}

result := <-results

if result != test {
wrongElement(t, result, test)
}

if _, ok := <-results; ok != false {
toManyElements(t)
}
}

func TestFindingElementPseudoEndlessRange(t *testing.T) {
tree := new(Tree)
test := "hello, world"
tree.Push(1, Inf, test)
tree.BuildTree()

results, err := tree.QueryIndex(9999)
if err != nil {
queryFailed(t, err)
}

result := <-results

if result != test {
wrongElement(t, result, test)
}

if _, ok := <-results; ok != false {
toManyElements(t)
}
}

func find(element interface{}, elements []interface{}) (bool, int) {
for i, e := range elements {
if element == e {
Expand Down

0 comments on commit c2e6f26

Please sign in to comment.