Skip to content

fix(assert): pass custom message through InEpsilonSlice#1899

Open
wyf027 wants to merge 1 commit into
stretchr:masterfrom
wyf027:fix/in-epsilon-slice-message
Open

fix(assert): pass custom message through InEpsilonSlice#1899
wyf027 wants to merge 1 commit into
stretchr:masterfrom
wyf027:fix/in-epsilon-slice-message

Conversation

@wyf027

@wyf027 wyf027 commented May 25, 2026

Copy link
Copy Markdown

Summary

  • InEpsilonSlice now forwards msgAndArgs to each per-element InEpsilon call
  • Keeps the existing "at index %d" hint and appends caller-provided context
  • Adds a regression test asserting custom messages appear in failure output

Fixes #763

Problem

InEpsilonSlice loops over elements and calls InEpsilon, but only passed an index hint and omitted msgAndArgs. Failures therefore lacked caller-provided context that other assertions include under Messages:.

InDeltaSlice already forwarded msgAndArgs; this aligns InEpsilonSlice with that behavior.

Test plan

  • go test ./assert/ -run TestInEpsilonSlice -v
  • Added TestInEpsilonSliceMessage verifying custom message appears in failure output

InEpsilonSlice delegates to InEpsilon per element but did not forward
msgAndArgs, so failure output omitted caller-provided context. Forward
the message args alongside the existing index hint.

Fixes stretchr#763

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread assert/assertions_test.go
0.04,
"custom context",
)
Contains(t, mockT.errorString(), "custom context")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to assert the full error here?

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.

assert.InEpsilonSlice doesn't print the message

2 participants