-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
assert: add position and pass msg to underlying func in InDeltaMapValues, InDeltaMapValues, and InEpsilonSlice #1514
base: master
Are you sure you want to change the base?
Conversation
e073c9f
to
0cd093d
Compare
a44a1b8
to
fcc8dfd
Compare
fcc8dfd
to
caa15c3
Compare
assert/assertions.go
Outdated
// appendMsgAndArgs appends a message string to the first element of the msgAndArgs slice | ||
// and returns the updated slice. | ||
func appendMsgAndArgs(msgAndArgs []interface{}, message string) []interface{} { | ||
if len(msgAndArgs) == 0 || msgAndArgs == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check of msgAndArgs == nil
is redundant. This is dead code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed, thanks!
} | ||
|
||
return msgAndArgs | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor the function body to use a switch
on len(msgAndArgs)
instead of multiple if
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for the review, I have adjusted the function to use switch
Summary
Add position and pass msg to underlying func in
InDeltaSlice
,InDeltaMapValues
, andInEpsilonSlice
Changes
msgAndArgs
slice in those 3 funcsat index:
for slice indexat key:
for map keyMotivation
When using those 3 functions, users don't know which key/index of the map/slice that produces the error because currently it's not added into the
msgAndArgs
slice.Example
InDeltaSlice
Before
After
InDeltaMapValues
Before
After
InEpsilonSlice
Before
After