MCPcopy
hub / github.com/stretchr/testify / InEpsilonSlice

Function InEpsilonSlice

assert/assertions.go:1593–1621  ·  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

1591
1592// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
1593func InEpsilonSlice(t TestingT, expected, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool {
1594 if h, ok := t.(tHelper); ok {
1595 h.Helper()
1596 }
1597
1598 if expected == nil || actual == nil {
1599 return Fail(t, "Parameters must be slice", msgAndArgs...)
1600 }
1601
1602 expectedSlice := reflect.ValueOf(expected)
1603 actualSlice := reflect.ValueOf(actual)
1604
1605 if expectedSlice.Type().Kind() != reflect.Slice {
1606 return Fail(t, "Expected value must be slice", msgAndArgs...)
1607 }
1608
1609 expectedLen := expectedSlice.Len()
1610 if !IsType(t, expected, actual) || !Len(t, actual, expectedLen) {
1611 return false
1612 }
1613
1614 for i := 0; i < expectedLen; i++ {
1615 if !InEpsilon(t, expectedSlice.Index(i).Interface(), actualSlice.Index(i).Interface(), epsilon, "at index %d", i) {
1616 return false
1617 }
1618 }
1619
1620 return true
1621}
1622
1623/*
1624 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