...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package s2
16
17 import (
18 "testing"
19 )
20
21 func TestEdgeVectorShapeEmpty(t *testing.T) {
22 var shape edgeVectorShape
23 if got, want := shape.NumEdges(), 0; got != want {
24 t.Errorf("shape.NumEdges() = %v, want %v", got, want)
25 }
26 if got, want := shape.NumChains(), 0; got != want {
27 t.Errorf("shape.NumChains() = %v, want %v", got, want)
28 }
29 if got, want := shape.Dimension(), 1; got != want {
30 t.Errorf("shape.Dimension() = %v, want %v", got, want)
31 }
32 if !shape.IsEmpty() {
33 t.Errorf("shape.IsEmpty() = false, want true")
34 }
35 if shape.IsFull() {
36 t.Errorf("shape.IsFull() = true, want false")
37 }
38 if shape.ReferencePoint().Contained {
39 t.Errorf("shape.ReferencePoint().Contained should be false")
40 }
41 }
42
43 func TestEdgeVectorShapeSingletonConstructor(t *testing.T) {
44 a := PointFromCoords(1, 0, 0)
45 b := PointFromCoords(0, 1, 0)
46
47 var shape Shape = edgeVectorShapeFromPoints(a, b)
48 if shape.NumEdges() != 1 {
49 t.Errorf("shape created from one edge should only have one edge, got %v", shape.NumEdges())
50 }
51 if shape.NumChains() != 1 {
52 t.Errorf("should only have one edge got %v", shape.NumChains())
53 }
54 edge := shape.Edge(0)
55
56 if edge.V0 != a {
57 t.Errorf("vertex 0 of the edge should be the same as was used to create it. got %v, want %v", edge.V0, a)
58 }
59 if edge.V1 != b {
60 t.Errorf("vertex 1 of the edge should be the same as was used to create it. got %v, want %v", edge.V1, b)
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
70
71
View as plain text