diff options
author | René 'Necoro' Neumann <necoro@necoro.eu> | 2021-02-16 00:30:13 +0100 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.eu> | 2021-02-16 00:30:13 +0100 |
commit | 3a854c3bc47e75491b836c7fc12b617da5d68288 (patch) | |
tree | aaecfbf79eea65efaa0e770e806d13d996990c39 /pkg/rfc822/writer_test.go | |
parent | c2b6e7ff346e3373a4e33c946594bb6f08393ad3 (diff) | |
download | feed2imap-go-3a854c3bc47e75491b836c7fc12b617da5d68288.tar.gz feed2imap-go-3a854c3bc47e75491b836c7fc12b617da5d68288.tar.bz2 feed2imap-go-3a854c3bc47e75491b836c7fc12b617da5d68288.zip |
Issue #46: Fix semantics of `n` result
Per contract, the returned number of bytes written should be the number of bytes _from the input_.
Therefore, the added bytes (`\r` or `\n`) shall not count into that number.
Diffstat (limited to 'pkg/rfc822/writer_test.go')
-rw-r--r-- | pkg/rfc822/writer_test.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/pkg/rfc822/writer_test.go b/pkg/rfc822/writer_test.go index 7beae8d..34c9d4a 100644 --- a/pkg/rfc822/writer_test.go +++ b/pkg/rfc822/writer_test.go @@ -34,10 +34,14 @@ func TestRfc822Writer_Write(t *testing.T) { t.Run(tt.before, func(t *testing.T) { b := bytes.Buffer{} w := Writer(&b) - if _, err := io.WriteString(w, tt.before); err != nil { + n, err := io.WriteString(w, tt.before) + if err != nil { t.Errorf("Error: %v", err) return } + if n != len(tt.before) { + t.Errorf("Unexpected number of bytes written: %d, expected: %d", n, len(tt.before)) + } res := b.String() if tt.after != res { t.Errorf("Expected: %q, got: %q", tt.after, res) |