-
-
Notifications
You must be signed in to change notification settings - Fork 315
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
fix(slice): fix bug in slice that produces new line for empty input slice #216
Conversation
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.
Great job! Not to minimise your work in the least, which is very welcome, but it's a little surprising that a fix like this has taken this long, isn't it?
script_test.go
Outdated
got, err := script.Slice([]string{"1", "2", "3"}).String() | ||
if err != nil { | ||
t.Fatal(err) | ||
tests := []struct { |
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.
It seems a shame to have a table test with just two cases, doesn't it? Especially as they're different cases, not two examples of the same behaviour.
Wouldn't you rather just structure this as two separate tests? That tends to make each test clearer, more focused, and easier to understand.
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.
done!
script.go
Outdated
@@ -182,6 +182,9 @@ func Post(url string) *Pipe { | |||
|
|||
// Slice creates a pipe containing each element of s, one per line. |
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.
// Slice creates a pipe containing each element of s, one per line. | |
// Slice creates a pipe containing each element of s, one per line. If s is | |
// empty or nil, then the pipe is empty. |
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.
Awesome! Thanks a lot!
This PR fixes #110 by handling an empty input into the
Slice
function.Added a new unit test