(t *testing.T)
| 114 | } |
| 115 | |
| 116 | func TestCovererRandomCaps(t *testing.T) { |
| 117 | rc := &RegionCoverer{MinLevel: 0, MaxLevel: 30, LevelMod: 1, MaxCells: 1} |
| 118 | for i := range 1000 { |
| 119 | rc.MinLevel = int(rand.Int31n(MaxLevel + 1)) |
| 120 | rc.MaxLevel = int(rand.Int31n(MaxLevel + 1)) |
| 121 | for rc.MinLevel > rc.MaxLevel { |
| 122 | rc.MinLevel = int(rand.Int31n(MaxLevel + 1)) |
| 123 | rc.MaxLevel = int(rand.Int31n(MaxLevel + 1)) |
| 124 | } |
| 125 | rc.LevelMod = int(1 + rand.Int31n(3)) |
| 126 | rc.MaxCells = skewedInt(10) |
| 127 | |
| 128 | maxArea := math.Min(4*math.Pi, float64(3*rc.MaxCells+1)*AvgAreaMetric.Value(rc.MinLevel)) |
| 129 | r := Region(randomCap(0.1*AvgAreaMetric.Value(MaxLevel), maxArea)) |
| 130 | |
| 131 | covering := rc.Covering(r) |
| 132 | checkCovering(t, rc, r, covering, false) |
| 133 | interior := rc.InteriorCovering(r) |
| 134 | checkCovering(t, rc, r, interior, true) |
| 135 | |
| 136 | // Check that Covering is deterministic. |
| 137 | covering2 := rc.Covering(r) |
| 138 | if !reflect.DeepEqual(covering, covering2) { |
| 139 | t.Errorf("Iteration %d, got covering = %v, want covering = %v", i, covering2, covering) |
| 140 | } |
| 141 | |
| 142 | // Also check Denormalize. The denormalized covering |
| 143 | // may still be different and smaller than "covering" because |
| 144 | // s2.RegionCoverer does not guarantee that it will not output all four |
| 145 | // children of the same parent. |
| 146 | covering.Denormalize(rc.MinLevel, rc.LevelMod) |
| 147 | checkCovering(t, rc, r, covering, false) |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | func TestRegionCovererInteriorCovering(t *testing.T) { |
| 152 | // We construct the region the following way. Start with Cell of level l. |
nothing calls this directly
no test coverage detected
searching dependent graphs…