Repository: stretchr/testify (go)

Issue:
InEpsilon does not fail when passed a NaN value
Hi! We ran into a small isue today with `require.InEpsilon`, at version 1.5.1

```go
func TestInEpsilonNaN(t *testing.T) {
	require.InEpsilon(t, 42, math.NaN(), 1)
}
```

Actual result : test passes

Expected result : an error

Pull request:
Make InEpsilon fail when given a NaN
fixes #918

Patch:
diff --git a/assert/assertions.go b/assert/assertions.go
index eefc89c..bfbe9cf 100644
--- a/assert/assertions.go
+++ b/assert/assertions.go
@@ -1245,6 +1245,9 @@ func calcRelativeError(expected, actual interface{}) (float64, error) {
 	if !aok {
 		return 0, fmt.Errorf("expected value %q cannot be converted to float", expected)
 	}
+	if math.IsNaN(af) {
+		return 0, errors.New("expected value must not be NaN")
+	}
 	if af == 0 {
 		return 0, fmt.Errorf("expected value must have a value other than zero to calculate the relative error")
 	}
@@ -1252,6 +1255,9 @@ func calcRelativeError(expected, actual interface{}) (float64, error) {
 	if !bok {
 		return 0, fmt.Errorf("actual value %q cannot be converted to float", actual)
 	}
+	if math.IsNaN(bf) {
+		return 0, errors.New("actual value must not be NaN")
+	}
 
 	return math.Abs(af-bf) / math.Abs(af), nil
 }
@@ -1261,6 +1267,9 @@ func InEpsilon(t TestingT, expected, actual interface{}, epsilon float64, msgAnd
 	if h, ok := t.(tHelper); ok {
 		h.Helper()
 	}
+	if math.IsNaN(epsilon) {
+		return Fail(t, "epsilon must not be NaN")
+	}
 	actualEpsilon, err := calcRelativeError(expected, actual)
 	if err != nil {
 		return Fail(t, err.Error(), msgAndArgs...)


Test patch:
diff --git a/assert/assertions_test.go b/assert/assertions_test.go
index 744a191..042cf68 100644
--- a/assert/assertions_test.go
+++ b/assert/assertions_test.go
@@ -1458,6 +1458,9 @@ func TestInEpsilon(t *testing.T) {
 		{0.1, -0.1, 1.99},
 		{0, 0.1, 2}, // expected must be different to zero
 		{time.Second, time.Second + 10*time.Millisecond, 0.002},
+		{math.NaN(), 0, 1},
+		{0, math.NaN(), 1},
+		{0, 0, math.NaN()},
 	}
 
 	for _, tc := range cases {