Skip to content

Commit 3a1f0cb

Browse files
committed
TestShapeutilRangeIteratorNext: Test sentinel id
1 parent 6188549 commit 3a1f0cb

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

s2/shapeutil_test.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,36 @@ func TestShapeutilRangeIteratorNext(t *testing.T) {
5353
// Create an index with one point each on CellID faces 0, 1, and 2.
5454
index := makeShapeIndex("0:0 | 0:90 | 90:0 # #")
5555
it := newRangeIterator(index)
56+
itCount := 0
57+
next := func() {
58+
itCount++
59+
it.next()
60+
if it.done() {
61+
t.Errorf("There should be 3 items in the index but there were only %d", itCount)
62+
}
63+
}
5664

5765
if got, want := it.cellID().Face(), 0; got != want {
5866
t.Errorf("it.CellID().Face() = %v, want %v", got, want)
5967
}
60-
it.next()
68+
next()
6169

6270
if got, want := it.cellID().Face(), 1; got != want {
6371
t.Errorf("it.CellID().Face() = %v, want %v", got, want)
6472
}
65-
it.next()
73+
next()
6674

6775
if got, want := it.cellID().Face(), 2; got != want {
6876
t.Errorf("it.CellID().Face() = %v, want %v", got, want)
6977
}
70-
it.next()
7178

79+
it.next()
7280
if !it.done() {
7381
t.Errorf("iterator over index of three items should be done after 3 calls to next")
7482
}
83+
if got, want := it.cellID(), SentinelCellID; got != want {
84+
t.Errorf("it.CellID() = %v, want %v", got, want)
85+
}
7586
}
7687

7788
func TestShapeutilRangeIteratorEmptyIndex(t *testing.T) {

0 commit comments

Comments
 (0)