MCPcopy
hub / github.com/expr-lang/expr / InDeltaSlice

Function InDeltaSlice

internal/testify/assert/assertions.go:1394–1415  ·  view source on GitHub ↗

InDeltaSlice is the same as InDelta, except it compares two slices.

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

Source from the content-addressed store, hash-verified

1392
1393// InDeltaSlice is the same as InDelta, except it compares two slices.
1394func InDeltaSlice(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
1395 if h, ok := t.(tHelper); ok {
1396 h.Helper()
1397 }
1398 if expected == nil || actual == nil ||
1399 reflect.TypeOf(actual).Kind() != reflect.Slice ||
1400 reflect.TypeOf(expected).Kind() != reflect.Slice {
1401 return Fail(t, "Parameters must be slice", msgAndArgs...)
1402 }
1403
1404 actualSlice := reflect.ValueOf(actual)
1405 expectedSlice := reflect.ValueOf(expected)
1406
1407 for i := 0; i < actualSlice.Len(); i++ {
1408 result := InDelta(t, actualSlice.Index(i).Interface(), expectedSlice.Index(i).Interface(), delta, msgAndArgs...)
1409 if !result {
1410 return result
1411 }
1412 }
1413
1414 return true
1415}
1416
1417// InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
1418func InDeltaMapValues(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {

Callers 4

InDeltaSliceFunction · 0.92
InDeltaSlicefFunction · 0.70
TestInDeltaSliceFunction · 0.70
InDeltaSliceMethod · 0.70

Calls 4

FailFunction · 0.70
InDeltaFunction · 0.70
HelperMethod · 0.45
LenMethod · 0.45

Tested by 1

TestInDeltaSliceFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…