Skip to content

Commit

Permalink
chore: more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danroc committed Nov 28, 2024
1 parent 7da1978 commit 2a82189
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions internal/itree/itree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package itree_test

import (
"fmt"
"slices"
"testing"

"github.com/danroc/geoblock/internal/itree"
Expand Down Expand Up @@ -110,8 +111,25 @@ func TestQueryDuplicate(t *testing.T) {
tree.Insert(itree.NewInterval[ComparableInt](1, 2), 1)
tree.Insert(itree.NewInterval[ComparableInt](1, 2), 1)

tree.Insert(itree.NewInterval[ComparableInt](3, 5), 1)
tree.Insert(itree.NewInterval[ComparableInt](3, 5), 1)
tree.Insert(itree.NewInterval[ComparableInt](3, 5), 2)
tree.Insert(itree.NewInterval[ComparableInt](2, 5), 2)

want := []int{1, 1}
tests := []struct {
key ComparableInt
matches []int
}{
{0, []int{}},
{1, []int{1, 1}},
{2, []int{1, 2, 1}},
{3, []int{2, 2}},
}

for _, test := range tests {
t.Run(fmt.Sprintf("Query(%d)", test.key), func(t *testing.T) {
matches := tree.Query(test.key)
if !slices.Equal(test.matches, matches) {
t.Errorf("expected %v, got %v", test.matches, matches)
}
})
}
}

0 comments on commit 2a82189

Please sign in to comment.