-
Notifications
You must be signed in to change notification settings - Fork 114
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
Covered UUID.decodePlain() with wrong input with a test #24
Conversation
@zerkms I just destroyed your branch, I'm sorry. :( |
It's fine, I need to include a tiny change there anyway :-) |
91b8200
to
36ec376
Compare
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.
LGTM.
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.
Looks good!
codec_test.go
Outdated
arg := []byte{'4', '2'} | ||
|
||
u := UUID{} | ||
err := u.decodePlain(arg) |
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.
@zerkms I might be nitpicking here a bit. Since we do not use the error value, how do we feel about simplifying this to the single if expression?
if u.decodePlain(arg) == 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.
The alternative I'd go with, if we care about the error type, would be:
var err error
// ...
if err = u.decodePlain(arg); err == nil {}
Just so that we assert the return type as being an error
value.
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.
I don't mind in either, but would personally prefer the first (given every other test case does not care about the exact returned err
type either).
36ec376
to
774487f
Compare
The
TestDecodePlainWithWrongLength
runs unexported method since there is no other way to reach that line.It's a substitution for the #22 which I accidentally closed via deleting my branch (instead of hard-push'ing it)