MCPcopy
hub / github.com/tdewolff/canvas / TestAngleBetween

Function TestAngleBetween

util_test.go:64–94  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

62}
63
64func TestAngleBetween(t *testing.T) {
65 var tests = []struct {
66 theta, lower, upper float64
67 between bool
68 }{
69 {0.0, 0.0, 1.0, true},
70 {1.0, 0.0, 1.0, true},
71 {0.5, 0.0, 1.0, true},
72 {0.5 + 2.0*math.Pi, 0.0, 1.0, true},
73 {0.5, 0.0 + 2.0*math.Pi, 1.0 + 2.0*math.Pi, true},
74 {0.5, 1.0 + 2.0*math.Pi, 0.0 + 2.0*math.Pi, true},
75 {0.5 - 2.0*math.Pi, 0.0, 1.0, true},
76 {0.5, 0.0 - 2.0*math.Pi, 1.0 - 2.0*math.Pi, true},
77 {0.5, 1.0 - 2.0*math.Pi, 0.0 - 2.0*math.Pi, true},
78 {-0.1, 0.0, 1.0, false},
79 {1.1, 0.0, 1.0, false},
80 {2.0, 3.0, 1.0, true},
81 {0.75 * math.Pi, 1.5 * math.Pi, 2.5 * math.Pi, false},
82
83 // tolerance
84 {0.0 - Epsilon, 0.0, 1.0, true},
85 {1.0 + Epsilon, 0.0, 1.0, true},
86 {0.0 - Epsilon, 1.0, 0.0, true},
87 {1.0 + Epsilon, 1.0, 0.0, true},
88 }
89 for _, tt := range tests {
90 t.Run(fmt.Sprintf("%g<=%g<=%g", tt.theta, tt.lower, tt.upper), func(t *testing.T) {
91 test.T(t, angleBetween(tt.theta, tt.lower, tt.upper), tt.between)
92 })
93 }
94}
95
96func TestAngleBetweenExclusive(t *testing.T) {
97 var tests = []struct {

Callers

nothing calls this directly

Calls 3

angleBetweenFunction · 0.85
TMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected