Skip to content

fix(assert): check slice lengths in InDeltaSlice and fix argument ordering - #1961

Open
aoright wants to merge 1 commit into
stretchr:masterfrom
aoright:fix/indeltaslice-length-check
Open

fix(assert): check slice lengths in InDeltaSlice and fix argument ordering#1961
aoright wants to merge 1 commit into
stretchr:masterfrom
aoright:fix/indeltaslice-length-check

Conversation

@aoright

@aoright aoright commented Sep 10, 2026

Copy link
Copy Markdown

In InDeltaSlice, if expected and actual had different lengths:

  • If expected had more elements than actual, the loop only iterated up to actualSlice.Len(), returning true even though slices differed.
  • If actual had more elements than expected, indexing expectedSlice.Index(i) panicked with reflect: slice index out of range.
    Additionally, InDelta was invoked with inverted arguments (actual was passed as expected).

This patch:

  1. Adds an explicit length check before element comparison so length mismatches fail cleanly with an informative message.
  2. Fixes the argument ordering passed to InDelta (expected then actual).
  3. Adds test cases covering mismatched slice lengths.

…ering

Signed-off-by: aoright <102943475+aoright@users.noreply.github.com>
@ccoVeille

ccoVeille commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

@ccoVeille

Copy link
Copy Markdown
Collaborator

Maybe it's time to fix all these 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants