InDeltaSlice is the same as InDelta, except it compares two slices.
(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{})
| 1426 | |
| 1427 | // InDeltaSlice is the same as InDelta, except it compares two slices. |
| 1428 | func InDeltaSlice(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { |
| 1429 | if h, ok := t.(tHelper); ok { |
| 1430 | h.Helper() |
| 1431 | } |
| 1432 | if expected == nil || actual == nil || |
| 1433 | reflect.TypeOf(actual).Kind() != reflect.Slice || |
| 1434 | reflect.TypeOf(expected).Kind() != reflect.Slice { |
| 1435 | return Fail(t, "Parameters must be slice", msgAndArgs...) |
| 1436 | } |
| 1437 | |
| 1438 | actualSlice := reflect.ValueOf(actual) |
| 1439 | expectedSlice := reflect.ValueOf(expected) |
| 1440 | |
| 1441 | for i := 0; i < actualSlice.Len(); i++ { |
| 1442 | result := InDelta(t, actualSlice.Index(i).Interface(), expectedSlice.Index(i).Interface(), delta, msgAndArgs...) |
| 1443 | if !result { |
| 1444 | return result |
| 1445 | } |
| 1446 | } |
| 1447 | |
| 1448 | return true |
| 1449 | } |
| 1450 | |
| 1451 | // InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. |
| 1452 | func InDeltaMapValues(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { |