InDeltaSlice is the same as InDelta, except it compares two slices.
(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{})
| 1392 | |
| 1393 | // InDeltaSlice is the same as InDelta, except it compares two slices. |
| 1394 | func 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. |
| 1418 | func InDeltaMapValues(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { |
searching dependent graphs…