(t *testing.T)
| 23 | ) |
| 24 | |
| 25 | func TestPaddedCellMethods(t *testing.T) { |
| 26 | // Test the PaddedCell methods that have approximate Cell equivalents. |
| 27 | for range 1000 { |
| 28 | cid := randomCellID() |
| 29 | padding := math.Pow(1e-15, randomFloat64()) |
| 30 | cell := CellFromCellID(cid) |
| 31 | pCell := PaddedCellFromCellID(cid, padding) |
| 32 | |
| 33 | if cell.id != pCell.id { |
| 34 | t.Errorf("%v.id = %v, want %v", pCell, pCell.id, cell.id) |
| 35 | } |
| 36 | if cell.id.Level() != pCell.Level() { |
| 37 | t.Errorf("%v.Level() = %v, want %v", pCell, pCell.Level(), cell.id.Level()) |
| 38 | } |
| 39 | |
| 40 | if padding != pCell.Padding() { |
| 41 | t.Errorf("%v.Padding() = %v, want %v", pCell, pCell.Padding(), padding) |
| 42 | } |
| 43 | |
| 44 | if got, want := pCell.Bound(), cell.BoundUV().ExpandedByMargin(padding); got != want { |
| 45 | t.Errorf("%v.BoundUV() = %v, want %v", pCell, got, want) |
| 46 | } |
| 47 | |
| 48 | r := r2.RectFromPoints(cell.id.centerUV()).ExpandedByMargin(padding) |
| 49 | if r != pCell.Middle() { |
| 50 | t.Errorf("%v.Middle() = %v, want %v", pCell, pCell.Middle(), r) |
| 51 | } |
| 52 | |
| 53 | if cell.id.Point() != pCell.Center() { |
| 54 | t.Errorf("%v.Center() = %v, want %v", pCell, pCell.Center(), cell.id.Point()) |
| 55 | } |
| 56 | if cid.IsLeaf() { |
| 57 | continue |
| 58 | } |
| 59 | |
| 60 | children, ok := cell.Children() |
| 61 | if !ok { |
| 62 | t.Errorf("%v.Children() failed but should not have", cell) |
| 63 | continue |
| 64 | } |
| 65 | for pos := range 4 { |
| 66 | i, j := pCell.ChildIJ(pos) |
| 67 | |
| 68 | cellChild := children[pos] |
| 69 | pCellChild := PaddedCellFromParentIJ(pCell, i, j) |
| 70 | if cellChild.id != pCellChild.id { |
| 71 | t.Errorf("%v.id = %v, want %v", pCellChild, pCellChild.id, cellChild.id) |
| 72 | } |
| 73 | if cellChild.id.Level() != pCellChild.Level() { |
| 74 | t.Errorf("%v.Level() = %v, want %v", pCellChild, pCellChild.Level(), cellChild.id.Level()) |
| 75 | } |
| 76 | |
| 77 | if padding != pCellChild.Padding() { |
| 78 | t.Errorf("%v.Padding() = %v, want %v", pCellChild, pCellChild.Padding(), padding) |
| 79 | } |
| 80 | |
| 81 | if got, want := pCellChild.Bound(), cellChild.BoundUV().ExpandedByMargin(padding); got != want { |
| 82 | t.Errorf("%v.BoundUV() = %v, want %v", pCellChild, got, want) |
nothing calls this directly
no test coverage detected
searching dependent graphs…