MCPcopy Index your code
hub / github.com/expr-lang/expr / InEpsilon

Function InEpsilon

internal/testify/assert/assertions.go:1484–1501  ·  view source on GitHub ↗

InEpsilon asserts that expected and actual have a relative error less than epsilon

(t TestingT, expected, actual interface{}, epsilon float64, msgAndArgs ...interface{})

Source from the content-addressed store, hash-verified

1482
1483// InEpsilon asserts that expected and actual have a relative error less than epsilon
1484func InEpsilon(t TestingT, expected, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool {
1485 if h, ok := t.(tHelper); ok {
1486 h.Helper()
1487 }
1488 if math.IsNaN(epsilon) {
1489 return Fail(t, "epsilon must not be NaN", msgAndArgs...)
1490 }
1491 actualEpsilon, err := calcRelativeError(expected, actual)
1492 if err != nil {
1493 return Fail(t, err.Error(), msgAndArgs...)
1494 }
1495 if actualEpsilon > epsilon {
1496 return Fail(t, fmt.Sprintf("Relative error is too high: %#v (expected)\n"+
1497 " < %#v (actual)", epsilon, actualEpsilon), msgAndArgs...)
1498 }
1499
1500 return true
1501}
1502
1503// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
1504func InEpsilonSlice(t TestingT, expected, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool {

Callers 5

InEpsilonFunction · 0.92
InEpsilonfFunction · 0.70
TestInEpsilonFunction · 0.70
InEpsilonSliceFunction · 0.70
InEpsilonMethod · 0.70

Calls 5

calcRelativeErrorFunction · 0.85
SprintfMethod · 0.80
FailFunction · 0.70
HelperMethod · 0.45
ErrorMethod · 0.45

Tested by 1

TestInEpsilonFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…