InDeltaSlice is the same as InDelta, except it compares two slices.
(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{})
| 1478 | |
| 1479 | // InDeltaSlice is the same as InDelta, except it compares two slices. |
| 1480 | func InDeltaSlice(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { |
| 1481 | if h, ok := t.(tHelper); ok { |
| 1482 | h.Helper() |
| 1483 | } |
| 1484 | if expected == nil || actual == nil || |
| 1485 | reflect.TypeOf(actual).Kind() != reflect.Slice || |
| 1486 | reflect.TypeOf(expected).Kind() != reflect.Slice { |
| 1487 | return Fail(t, "Parameters must be slice", msgAndArgs...) |
| 1488 | } |
| 1489 | |
| 1490 | actualSlice := reflect.ValueOf(actual) |
| 1491 | expectedSlice := reflect.ValueOf(expected) |
| 1492 | |
| 1493 | for i := 0; i < actualSlice.Len(); i++ { |
| 1494 | result := InDelta(t, actualSlice.Index(i).Interface(), expectedSlice.Index(i).Interface(), delta, msgAndArgs...) |
| 1495 | if !result { |
| 1496 | return result |
| 1497 | } |
| 1498 | } |
| 1499 | |
| 1500 | return true |
| 1501 | } |
| 1502 | |
| 1503 | // InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. |
| 1504 | func InDeltaMapValues(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { |