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

Function TestPointVectorBasics

s2/point_vector_test.go:44–86  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

42}
43
44func TestPointVectorBasics(t *testing.T) {
45 const numPoints = 100
46 var p PointVector = make([]Point, numPoints)
47
48 for i := range numPoints {
49 p[i] = randomPoint()
50 }
51
52 shape := Shape(&p)
53 if got, want := shape.NumEdges(), numPoints; got != want {
54 t.Errorf("shape.NumEdges() = %v, want %v", got, want)
55 }
56 if got, want := shape.NumChains(), numPoints; got != want {
57 t.Errorf("shape.NumChains() = %v, want %v", got, want)
58 }
59 if got, want := shape.Dimension(), 0; got != want {
60 t.Errorf("shape.Dimension() = %v, want %v", got, want)
61 }
62 if shape.IsEmpty() {
63 t.Errorf("shape.IsEmpty() = true, want false")
64 }
65 if shape.IsFull() {
66 t.Errorf("shape.IsFull() = true, want false")
67 }
68
69 for i := range numPoints {
70 if got, want := shape.Chain(i).Start, i; got != want {
71 t.Errorf("shape.Chain(%d).Start = %d, want %d", i, got, want)
72 }
73 if got, want := shape.Chain(i).Length, 1; got != want {
74 t.Errorf("shape.Chain(%d).Length = %v, want %d", i, got, want)
75 }
76 edge := shape.Edge(i)
77 pt := p[i]
78
79 if !pt.ApproxEqual(edge.V0) {
80 t.Errorf("shape.Edge(%d).V0 = %v, want %v", i, edge.V0, pt)
81 }
82 if !pt.ApproxEqual(edge.V1) {
83 t.Errorf("shape.Edge(%d).V1 = %v, want %v", i, edge.V1, pt)
84 }
85 }
86}
87
88// TODO(rsned): Differences from C++
89// TEST(S2PointVectorShape, ChainIteratorWorks) {

Callers

nothing calls this directly

Calls 10

randomPointFunction · 0.85
ShapeInterface · 0.85
NumEdgesMethod · 0.65
NumChainsMethod · 0.65
DimensionMethod · 0.65
IsEmptyMethod · 0.65
IsFullMethod · 0.65
ChainMethod · 0.65
EdgeMethod · 0.65
ApproxEqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…