(t *testing.T)
| 42 | } |
| 43 | |
| 44 | func 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) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…