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

Function TestAngleTime

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

Source from the content-addressed store, hash-verified

30}
31
32func TestAngleTime(t *testing.T) {
33 var tests = []struct {
34 theta, lower, upper float64
35 t float64
36 }{
37 {0.0, 0.0, 1.0, 0.0},
38 {1.0, 0.0, 1.0, 1.0},
39 {0.5, 0.0, 1.0, 0.5},
40 {0.5 + 2.0*math.Pi, 0.0, 1.0, 0.5},
41 {0.5, 0.0 + 2.0*math.Pi, 1.0 + 2.0*math.Pi, 0.5},
42 {0.5, 1.0 + 2.0*math.Pi, 0.0 + 2.0*math.Pi, 0.5},
43 {0.5 - 2.0*math.Pi, 0.0, 1.0, 0.5},
44 {0.5, 0.0 - 2.0*math.Pi, 1.0 - 2.0*math.Pi, 0.5},
45 {0.5, 1.0 - 2.0*math.Pi, 0.0 - 2.0*math.Pi, 0.5},
46 {-0.1, 0.0, 1.0, 2.0*math.Pi - 0.1},
47 {1.1, 0.0, 1.0, 1.1},
48 {2.0, 3.0, 1.0, 0.5},
49 {0.75 * math.Pi, 1.5 * math.Pi, 2.5 * math.Pi, 1.25},
50
51 // tolerance
52 {0.0 - Epsilon, 0.0, 1.0, 0.0},
53 {1.0 + Epsilon, 0.0, 1.0, 1.0},
54 {0.0 - Epsilon, 1.0, 0.0, 1.0},
55 {1.0 + Epsilon, 1.0, 0.0, 0.0},
56 }
57 for _, tt := range tests {
58 t.Run(fmt.Sprintf("%g<=%g<=%g", tt.theta, tt.lower, tt.upper), func(t *testing.T) {
59 test.FloatDiff(t, angleTime(tt.theta, tt.lower, tt.upper), tt.t, 1e-9)
60 })
61 }
62}
63
64func TestAngleBetween(t *testing.T) {
65 var tests = []struct {

Callers

nothing calls this directly

Calls 2

angleTimeFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected