-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgfx_test.go
More file actions
31 lines (24 loc) · 593 Bytes
/
Copy pathgfx_test.go
File metadata and controls
31 lines (24 loc) · 593 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package gfx
import (
"math"
"testing"
)
func inDelta(t *testing.T, expected, actual, delta float64) bool {
t.Helper()
if math.IsNaN(expected) && math.IsNaN(actual) {
return true
}
if math.IsNaN(expected) {
t.Error("Expected must not be NaN")
return false
}
if math.IsNaN(actual) {
t.Errorf("Expected %v with delta %v, but was NaN", expected, delta)
return false
}
if dt := expected - actual; dt < -delta || dt > delta {
t.Errorf("Max difference between %v and %v allowed is %v, but difference was %v", expected, actual, delta, dt)
return false
}
return true
}