Skip to content

Commit

Permalink
fix encoding chunkSize
Browse files Browse the repository at this point in the history
  • Loading branch information
convto committed May 8, 2022
1 parent 9874839 commit 8a4aa91
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bit.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func NewEncoder(w io.Writer) io.Writer {

func (e *encoder) Write(p []byte) (n int, err error) {
for len(p) > 0 && e.err == nil {
chunkSize := bufferSize / 2
chunkSize := bufferSize / 8
if len(p) < chunkSize {
chunkSize = len(p)
}
Expand Down
4 changes: 2 additions & 2 deletions bit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func TestEncoderDecoder(t *testing.T) {
var buf bytes.Buffer
enc := NewEncoder(&buf)
r := struct{ io.Reader }{bytes.NewReader(input)} // io.Reader only; not io.WriterTo
if n, err := io.CopyBuffer(enc, r, make([]byte, 7)); n != int64(len(input)) || err != nil {
if n, err := io.CopyBuffer(enc, r, nil); n != int64(len(input)) || err != nil {
t.Errorf("encoder.Write(%q*%d) = (%d, %v), want (%d, nil)", test.dec, multiplier, n, err, len(input))
continue
}
Expand All @@ -126,7 +126,7 @@ func TestEncoderDecoder(t *testing.T) {
dec := NewDecoder(&buf)
var decBuf bytes.Buffer
w := struct{ io.Writer }{&decBuf} // io.Writer only; not io.ReaderFrom
if _, err := io.CopyBuffer(w, dec, make([]byte, 7)); err != nil || decBuf.Len() != len(input) {
if _, err := io.CopyBuffer(w, dec, nil); err != nil || decBuf.Len() != len(input) {
t.Errorf("decoder.Read(%q*%d) = (%d, %v), want (%d, nil)", test.enc, multiplier, decBuf.Len(), err, len(input))
}

Expand Down

0 comments on commit 8a4aa91

Please sign in to comment.