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

Function TestLoopBasic

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

Source from the content-addressed store, hash-verified

217}
218
219func TestLoopBasic(t *testing.T) {
220 shape := Shape(makeLoop("0:0, 0:1, 1:0"))
221
222 if got, want := shape.NumEdges(), 3; got != want {
223 t.Errorf("shape.NumEdges() = %d, want %d", got, want)
224 }
225 if got, want := shape.NumChains(), 1; got != 1 {
226 t.Errorf("shape.NumChains() = %d, want %d", got, want)
227 }
228 if got, want := shape.Chain(0).Start, 0; got != 0 {
229 t.Errorf("shape.Chain(0).Start = %d, want %d", got, want)
230 }
231 if got, want := shape.Chain(0).Length, 3; got != want {
232 t.Errorf("shape.Chain(0).Length = %d, want %d", got, want)
233 }
234
235 e := shape.Edge(2)
236 if want := PointFromLatLng(LatLngFromDegrees(1, 0)); !e.V0.ApproxEqual(want) {
237 t.Errorf("shape.Edge(2) end A = %v, want %v", e.V0, want)
238 }
239 if want := PointFromLatLng(LatLngFromDegrees(0, 0)); !e.V1.ApproxEqual(want) {
240 t.Errorf("shape.Edge(2) end B = %v, want %v", e.V1, want)
241 }
242 if got, want := shape.Dimension(), 2; got != want {
243 t.Errorf("shape.Dimension() = %v, want %v", got, want)
244 }
245 if shape.IsEmpty() {
246 t.Errorf("shape.IsEmpty() = true, want false")
247 }
248 if shape.IsFull() {
249 t.Errorf("shape.IsFull() = true, want false")
250 }
251 if shape.ReferencePoint().Contained {
252 t.Errorf("shape.ReferencePoint().Contained = true, want false")
253 }
254}
255
256func TestLoopHoleAndSign(t *testing.T) {
257 l := LoopFromPoints(parsePoints("0:-180, 0:-90, 0:0, 0:90"))

Callers

nothing calls this directly

Calls 13

ShapeInterface · 0.85
makeLoopFunction · 0.85
PointFromLatLngFunction · 0.85
LatLngFromDegreesFunction · 0.85
NumEdgesMethod · 0.65
NumChainsMethod · 0.65
ChainMethod · 0.65
EdgeMethod · 0.65
DimensionMethod · 0.65
IsEmptyMethod · 0.65
IsFullMethod · 0.65
ReferencePointMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…