Bug fixes and improvements for corner cases #89
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When working on #88 , I noticed some defects in the current library, so I'd like to submit this separate patch, which does the following:
Fix the defect that Column() crashes on zero or a negative input
The library panics when the following code is run
After the change, the program will return an empty pipe.
Fix the defect that Last() crashes on a negative input
The library panics when the following code is run
After the change, the program will return an empty pipe.
Fix the defect that Regex filters crash on a nil regex expression
The library panics when the following code is run
After the change, the program will return a pipe with the error "nil regular expression"
Add unit test for WithError(); close the pipe when a non-nil error is set
When fixing the regex defect, I just wrote
Then, I realized that
p
will not be automatically closed, since the subsequent filters and sinks will catch the error and return immediately. To fix this problem and prevent contributors from making the same mistake in the future, I think the best approach is to just close the pipe reader when a non-nil error is set.Add ExecForEach, Reject(), and RejectRegexp to doMethodsOnPipe tests
Just some jobs that previous contributors forgot.
Improve coverage by adding equal counts in the test case of Freq
To test that lines are sorted in alphabetical order when there is a tie.
Use io.Copy() in Stdout() to improve efficiency
It seems unnecessary to write the pipe's reader into a string and then print it.
By the way, after all the changes, the total line coverage has risen from 92.7% to 93.8%.