MCPcopy Create free account
hub / github.com/stretchr/testify / InEpsilonSlice

Function InEpsilonSlice

assert/assertions.go:1541–1569  ·  view source on GitHub ↗

InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.

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

Source from the content-addressed store, hash-verified

1539
1540// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
1541func InEpsilonSlice(t TestingT, expected, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool {
1542 if h, ok := t.(tHelper); ok {
1543 h.Helper()
1544 }
1545
1546 if expected == nil || actual == nil {
1547 return Fail(t, "Parameters must be slice", msgAndArgs...)
1548 }
1549
1550 expectedSlice := reflect.ValueOf(expected)
1551 actualSlice := reflect.ValueOf(actual)
1552
1553 if expectedSlice.Type().Kind() != reflect.Slice {
1554 return Fail(t, "Expected value must be slice", msgAndArgs...)
1555 }
1556
1557 expectedLen := expectedSlice.Len()
1558 if !IsType(t, expected, actual) || !Len(t, actual, expectedLen) {
1559 return false
1560 }
1561
1562 for i := 0; i < expectedLen; i++ {
1563 if !InEpsilon(t, expectedSlice.Index(i).Interface(), actualSlice.Index(i).Interface(), epsilon, "at index %d", i) {
1564 return false
1565 }
1566 }
1567
1568 return true
1569}
1570
1571/*
1572 Errors

Callers 4

InEpsilonSliceFunction · 0.92
InEpsilonSlicefFunction · 0.70
TestInEpsilonSliceFunction · 0.70
InEpsilonSliceMethod · 0.70

Calls 6

FailFunction · 0.70
IsTypeFunction · 0.70
LenFunction · 0.70
InEpsilonFunction · 0.70
HelperMethod · 0.65
LenMethod · 0.45

Tested by 1

TestInEpsilonSliceFunction · 0.56