Repository navigation
Conversation
InDeltaSlice only iterated over the actual slice, so comparing slices of
different lengths could pass as long as every element of the shorter
slice matched, e.g.:
assert.InDeltaSlice(t, []float64{1, 2}, []float64{1}, 0.001) // passed
This is inconsistent with InEpsilonSlice, which already enforces equal
length. Add the same length check so mismatched-length slices fail.
Fixes stretchr#1263
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1263.
Problem
InDeltaSliceonly iterates over the actual slice, so two slices of different lengths can pass as long as every element of the shorter one matches:As @dolmen noted in the issue, this is inconsistent with
InEpsilonSlice, which already enforces equal length viaLen(t, actual, expectedLen), and it should be fixed without waiting for v2.0.0.Fix
Add a length check to
InDeltaSlicebefore the element-wise comparison, mirroringInEpsilonSlice:Testing
TestInDeltaSlicewith both length-mismatch directions (shorter actual and longer actual); both now correctly fail.go test ./assert/andgo test ./require/pass (no regression).go vet ./assert/clean.