MCPcopy
hub / github.com/golang/geo / testCellChildren

Function testCellChildren

s2/cell_test.go:165–334  ·  view source on GitHub ↗
(t *testing.T, cell Cell)

Source from the content-addressed store, hash-verified

163}
164
165func testCellChildren(t *testing.T, cell Cell) {
166 children, ok := cell.Children()
167 if cell.IsLeaf() && !ok {
168 return
169 }
170 if cell.IsLeaf() && ok {
171 t.Errorf("leaf cells should not be able to return children. cell %v", cell)
172 }
173
174 if !ok {
175 t.Errorf("unable to get Children for %v", cell)
176 return
177 }
178
179 childID := cell.id.ChildBegin()
180 for i, ci := range children {
181 // Check that the child geometry is consistent with its cell ID.
182 if childID != ci.id {
183 t.Errorf("%v.child[%d].id = %v, want %v", cell, i, ci.id, childID)
184 }
185
186 direct := CellFromCellID(childID)
187 if !ci.Center().ApproxEqual(childID.Point()) {
188 t.Errorf("%v.Center() = %v, want %v", ci, ci.Center(), childID.Point())
189 }
190 if ci.face != direct.face {
191 t.Errorf("%v.face = %v, want %v", ci, ci.face, direct.face)
192 }
193 if ci.level != direct.level {
194 t.Errorf("%v.level = %v, want %v", ci, ci.level, direct.level)
195 }
196 if ci.orientation != direct.orientation {
197 t.Errorf("%v.orientation = %v, want %v", ci, ci.orientation, direct.orientation)
198 }
199 if !ci.Center().ApproxEqual(direct.Center()) {
200 t.Errorf("%v.Center() = %v, want %v", ci, ci.Center(), direct.Center())
201 }
202
203 for k := range 4 {
204 if !direct.VertexRaw(k).ApproxEqual(ci.VertexRaw(k)) {
205 t.Errorf("child %d %v.VertexRaw(%d) = %v, want %v", i, ci, k, ci.VertexRaw(k), direct.VertexRaw(k))
206 }
207 if direct.EdgeRaw(k) != ci.EdgeRaw(k) {
208 t.Errorf("child %d %v.EdgeRaw(%d) = %v, want %v", i, ci, k, ci.EdgeRaw(k), direct.EdgeRaw(k))
209 }
210 }
211
212 // Test ContainsCell() and IntersectsCell().
213 if !cell.ContainsCell(ci) {
214 t.Errorf("%v.ContainsCell(%v) = false, want true", cell, ci)
215 }
216 if !cell.IntersectsCell(ci) {
217 t.Errorf("%v.IntersectsCell(%v) = false, want true", cell, ci)
218 }
219 if ci.ContainsCell(cell) {
220 t.Errorf("%v.ContainsCell(%v) = true, want false", ci, cell)
221 }
222 if !cell.ContainsPoint(ci.Center()) {

Callers 1

TestCellChildrenFunction · 0.85

Calls 15

CellFromCellIDFunction · 0.85
PointFromCoordsFunction · 0.85
ChildBeginMethod · 0.80
PointMethod · 0.80
VertexRawMethod · 0.80
EdgeRawMethod · 0.80
BoundUVMethod · 0.80
ContainsCellMethod · 0.65
IntersectsCellMethod · 0.65
ContainsPointMethod · 0.65
CapBoundMethod · 0.65
RectBoundMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…