Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions assert/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1497,6 +1497,10 @@ func InDeltaSlice(t TestingT, expected, actual interface{}, delta float64, msgAn
actualSlice := reflect.ValueOf(actual)
expectedSlice := reflect.ValueOf(expected)

if actualSlice.Len() != expectedSlice.Len() {
Comment thread
puneetdixit200 marked this conversation as resolved.
Outdated
return Fail(t, "Arguments must have the same number of elements", msgAndArgs...)
}

for i := 0; i < actualSlice.Len(); i++ {
result := InDelta(t, actualSlice.Index(i).Interface(), expectedSlice.Index(i).Interface(), delta, msgAndArgs...)
if !result {
Expand Down
10 changes: 10 additions & 0 deletions assert/assertions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2359,6 +2359,16 @@ func TestInDeltaSlice(t *testing.T) {
[]float64{0, math.NaN(), 3},
0.1), "{1, NaN, 2} is not element-wise close to {0, NaN, 3} in delta=0.1")

False(t, InDeltaSlice(mockT,
[]float64{1, 2},
[]float64{1},
0.1), "Expected slices with extra expected values to fail")

False(t, InDeltaSlice(mockT,
[]float64{1},
[]float64{1, 2},
0.1), "Expected slices with extra actual values to fail")

False(t, InDeltaSlice(mockT, "", nil, 1), "Expected non numeral slices to fail")
}

Expand Down