mirror of
https://github.com/wneessen/go-mail.git
synced 2024-12-22 10:40:39 +01:00
Update Base64LineBreaker_Write testing
Enhanced testing for the Base64LineBreaker_Write function by adding a fuzz test. This additional fuzz test provides the function with a variety of random byte inputs as a way of uncovering any hidden errors and contributing to more reliable coding.
This commit is contained in:
parent
280f85abd1
commit
821ee0a9e1
1 changed files with 9 additions and 2 deletions
|
@ -5,6 +5,7 @@
|
|||
package mail
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
|
@ -463,12 +464,18 @@ func (e errorWriter) Close() error {
|
|||
}
|
||||
|
||||
func FuzzBase64LineBreaker_Write(f *testing.F) {
|
||||
f.Add([]byte(logoB64))
|
||||
f.Add([]byte("abc"))
|
||||
f.Add([]byte("def"))
|
||||
f.Add([]uint8{00, 01, 02, 30, 255})
|
||||
buf := bytes.Buffer{}
|
||||
bw := bufio.NewWriter(&buf)
|
||||
f.Fuzz(func(t *testing.T, data []byte) {
|
||||
b := &Base64LineBreaker{out: &buf}
|
||||
b := &Base64LineBreaker{out: bw}
|
||||
if _, err := b.Write(data); err != nil {
|
||||
t.Errorf("failed to write to B64LineBreaker: %s", err)
|
||||
}
|
||||
if err := b.Close(); err != nil {
|
||||
t.Errorf("failed to close B64LineBreaker: %s", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue