Skip to content

Commit

Permalink
CR fixes - add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
erankor committed Jul 26, 2023
1 parent e016547 commit 092a99b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func (p *Part) encodeContentFromReader(b *bufio.Writer) error {
enc := base64.StdEncoding

chunk := make([]byte, readChunkSize) // contains a whole number of lines
copy(chunk, p.Content)
copy(chunk, p.Content) // copy the data of the initial read that was issued by `Encode`
n := len(p.Content)

for {
Expand Down
4 changes: 3 additions & 1 deletion encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ func TestEncodePartQuotedPrintableHeaders(t *testing.T) {
test.DiffGolden(t, b.Bytes(), "testdata", "encode", "part-quoted-printable-headers.golden")
}

// oneByOneReader implements io.Reader over a byte slice, returns a single byte on every Read request.
// This object is used to validate that partial reads (=read calls that return n<len(p)) are handled correctly.
type oneByOneReader struct {
content []byte
pos int
Expand Down Expand Up @@ -149,7 +151,7 @@ func TestEncodePartContentReader(t *testing.T) {
t.Fatal(err)
}

// encode the part using byte slice
// encode the part using `Content` byte slice stored in the Part
b1 := &bytes.Buffer{}
err = p.Encode(b1)
if err != nil {
Expand Down

0 comments on commit 092a99b

Please sign in to comment.