-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
Description
Description
As far as I read the code calcRelativeError() is wrong for "expected" values lower than 1
The division is an error for values in interval 0..1
math.Abs(af-bf) / math.Abs(af)
// example:
abs(0.1-0.14) / abs(0.1)
0.04 / 0.1
0.4
Step To Reproduce
func TestFoo(t *testing.T) {
expected := 0.1
epsilon := 0.2
successRate := 0.14
if !assert.InEpsilon(t, expected, successRate, epsilon, fmt.Sprintf("Test should have a success rate between %0.2f < %0.2f < %0.2f", expected-epsilon, successRate, expected+epsilon)) {
t.Fatal("FAIL")
}
}
Expected behavior
success
Actual behavior
--- FAIL: TestFoo (0.00s)
Error: Relative error is too high: 0.2 (expected)
< 0.4000000000000001 (actual)
Test: TestFoo
Messages: Test should have a success rate between -0.10 < 0.14 < 0.30
redis_test.go:614: FAIL
FAIL