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

Function TestLoopContainsPoint

s2/loop_test.go:395–486  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

393}
394
395func TestLoopContainsPoint(t *testing.T) {
396 north := Point{r3.Vector{X: 0, Y: 0, Z: 1}}
397 south := Point{r3.Vector{X: 0, Y: 0, Z: -1}}
398 east := PointFromCoords(0, 1, 0)
399 west := PointFromCoords(0, -1, 0)
400
401 if EmptyLoop().ContainsPoint(north) {
402 t.Errorf("empty loop should not have any points")
403 }
404 if !FullLoop().ContainsPoint(south) {
405 t.Errorf("full loop should have full point vertex")
406 }
407
408 for _, tc := range []struct {
409 name string
410 l *Loop
411 in Point
412 out Point
413 }{
414 {
415 "north hemisphere",
416 northHemi,
417 north,
418 south,
419 },
420 {
421 "south hemisphere",
422 southHemi,
423 south,
424 north,
425 },
426 {
427 "west hemisphere",
428 westHemi,
429 west,
430 east,
431 },
432 {
433 "east hemisphere",
434 eastHemi,
435 east,
436 west,
437 },
438 {
439 "candy cane",
440 candyCane,
441 PointFromLatLng(LatLngFromDegrees(5, 71)),
442 PointFromLatLng(LatLngFromDegrees(-8, 71)),
443 },
444 } {
445 l := tc.l
446 for i := range 4 {
447 if !l.ContainsPoint(tc.in) {
448 t.Errorf("%s loop should contain %v at rotation %d", tc.name, tc.in, i)
449 }
450 if l.ContainsPoint(tc.out) {
451 t.Errorf("%s loop shouldn't contain %v at rotation %d", tc.name, tc.out, i)
452 }

Callers

nothing calls this directly

Calls 15

PointFromCoordsFunction · 0.85
EmptyLoopFunction · 0.85
FullLoopFunction · 0.85
PointFromLatLngFunction · 0.85
LatLngFromDegreesFunction · 0.85
rotateFunction · 0.85
CellIDFromFaceFunction · 0.85
CellFromCellIDFunction · 0.85
LoopFromPointsFunction · 0.85
ChildBeginAtLevelMethod · 0.80
ChildEndAtLevelMethod · 0.80
ContainsPointMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…