(t *testing.T)
| 452 | } |
| 453 | |
| 454 | func TestCapContainsCell(t *testing.T) { |
| 455 | faceRadius := math.Atan(math.Sqrt2) |
| 456 | for face := range 6 { |
| 457 | // The cell consisting of the entire face. |
| 458 | rootCell := CellFromCellID(CellIDFromFace(face)) |
| 459 | |
| 460 | // A leaf cell at the midpoint of the v=1 edge. |
| 461 | edgeCell := CellFromPoint(Point{faceUVToXYZ(face, 0, 1-epsilon)}) |
| 462 | |
| 463 | // A leaf cell at the u=1, v=1 corner |
| 464 | cornerCell := CellFromPoint(Point{faceUVToXYZ(face, 1-epsilon, 1-epsilon)}) |
| 465 | |
| 466 | // Quick check for full and empty caps. |
| 467 | if !fullCap.ContainsCell(rootCell) { |
| 468 | t.Errorf("Cap(%v).ContainsCell(%v) = %t; want = %t", fullCap, rootCell, false, true) |
| 469 | } |
| 470 | |
| 471 | // Check intersections with the bounding caps of the leaf cells that are adjacent to |
| 472 | // cornerCell along the Hilbert curve. Because this corner is at (u=1,v=1), the curve |
| 473 | // stays locally within the same cube face. |
| 474 | first := cornerCell.id.Advance(-3) |
| 475 | last := cornerCell.id.Advance(4) |
| 476 | for id := first; id < last; id = id.Next() { |
| 477 | c := CellFromCellID(id).CapBound() |
| 478 | if got, want := c.ContainsCell(cornerCell), id == cornerCell.id; got != want { |
| 479 | t.Errorf("Cap(%v).ContainsCell(%v) = %t; want = %t", c, cornerCell, got, want) |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | for capFace := range 6 { |
| 484 | // A cap that barely contains all of capFace. |
| 485 | center := unitNorm(capFace) |
| 486 | covering := CapFromCenterAngle(center, s1.Angle(faceRadius+epsilon)) |
| 487 | if got, want := covering.ContainsCell(rootCell), capFace == face; got != want { |
| 488 | t.Errorf("Cap(%v).ContainsCell(%v) = %t; want = %t", covering, rootCell, got, want) |
| 489 | } |
| 490 | if got, want := covering.ContainsCell(edgeCell), center.Dot(edgeCell.id.Point().Vector) > 0.1; got != want { |
| 491 | t.Errorf("Cap(%v).ContainsCell(%v) = %t; want = %t", covering, edgeCell, got, want) |
| 492 | } |
| 493 | if got, want := covering.ContainsCell(edgeCell), covering.IntersectsCell(edgeCell); got != want { |
| 494 | t.Errorf("Cap(%v).ContainsCell(%v) = %t; want = %t", covering, edgeCell, got, want) |
| 495 | } |
| 496 | if got, want := covering.ContainsCell(cornerCell), capFace == face; got != want { |
| 497 | t.Errorf("Cap(%v).ContainsCell(%v) = %t; want = %t", covering, cornerCell, got, want) |
| 498 | } |
| 499 | |
| 500 | // A cap that barely intersects the edges of capFace. |
| 501 | bulging := CapFromCenterAngle(center, s1.Angle(math.Pi/4+epsilon)) |
| 502 | if bulging.ContainsCell(rootCell) { |
| 503 | t.Errorf("Cap(%v).ContainsCell(%v) = %t; want = %t", bulging, rootCell, true, false) |
| 504 | } |
| 505 | if got, want := bulging.ContainsCell(edgeCell), capFace == face; got != want { |
| 506 | t.Errorf("Cap(%v).ContainsCell(%v) = %t; want = %t", bulging, edgeCell, got, want) |
| 507 | } |
| 508 | if bulging.ContainsCell(cornerCell) { |
| 509 | t.Errorf("Cap(%v).ContainsCell(%v) = %t; want = %t", bulging, cornerCell, true, false) |
| 510 | } |
| 511 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…