Repository: stretchr/testify (go)

Issue:
InEpsilon has inconsistent results with expected or actual values of Inf
```go
func TestInEpsilon1(t *testing.T) {
	div := 0.0
	require.InEpsilon(t, 1, 1/div, 0.001)
}

func TestInEpsilon2(t *testing.T) {
	div := 0.0
	require.InEpsilon(t, 1/div, 1, 0.001)
}
```

```
> go test -v -run InEps | grep -E '(PASS|FAIL)'
--- FAIL: TestInEpsilon1 (0.00s)
--- PASS: TestInEpsilon2 (0.00s)
```

_Originally posted by @ybrustin-te in https://github.com/stretchr/testify/issues/918#issuecomment-2416889992_

Given the difference between two Inf values cannot be determined, those assertions should both fail.

Pull request description:
Fix issue #1662 (comparing infs should fail)
## Summary
Comparing Infs should fail as described in related issue

## Related issues
Closes #1662 


Patch:
diff --git a/assert/assertions.go b/assert/assertions.go
index b9a2b44..bfb640a 100644
--- a/assert/assertions.go
+++ b/assert/assertions.go
@@ -1512,6 +1512,9 @@ func InEpsilon(t TestingT, expected, actual interface{}, epsilon float64, msgAnd
 	if err != nil {
 		return Fail(t, err.Error(), msgAndArgs...)
 	}
+	if math.IsNaN(actualEpsilon) {
+		return Fail(t, "relative error is NaN", msgAndArgs...)
+	}
 	if actualEpsilon > epsilon {
 		return Fail(t, fmt.Sprintf("Relative error is too high: %#v (expected)\n"+
 			"        < %#v (actual)", epsilon, actualEpsilon), msgAndArgs...)


Test patch:
diff --git a/assert/assertions_test.go b/assert/assertions_test.go
index ad5c1be..ca12599 100644
--- a/assert/assertions_test.go
+++ b/assert/assertions_test.go
@@ -2036,6 +2036,14 @@ func TestInEpsilon(t *testing.T) {
 		{math.NaN(), 0, 1},
 		{0, math.NaN(), 1},
 		{0, 0, math.NaN()},
+		{math.Inf(1), 1, 1},
+		{math.Inf(-1), 1, 1},
+		{1, math.Inf(1), 1},
+		{1, math.Inf(-1), 1},
+		{math.Inf(1), math.Inf(1), 1},
+		{math.Inf(1), math.Inf(-1), 1},
+		{math.Inf(-1), math.Inf(1), 1},
+		{math.Inf(-1), math.Inf(-1), 1},
 	}
 
 	for _, tc := range cases {