Add fuzz testing to Base64LineBreaker_Write function

The update enhances testing for the Base64LineBreaker_Write function by creating a fuzz test. This new fuzz test feeds the function with a wide range of random byte inputs to improve the detection of hidden anomalies and help ensure more robust code.
This commit is contained in:
Winni Neessen 2024-03-23 16:14:07 +01:00
parent 932ac2be48
commit 280f85abd1
Signed by: wneessen
GPG key ID: 5F3AF39B820C119D

View file

@ -461,3 +461,14 @@ func (e errorWriter) Write([]byte) (int, error) {
func (e errorWriter) Close() error {
return fmt.Errorf("supposed to always fail")
}
func FuzzBase64LineBreaker_Write(f *testing.F) {
f.Add([]byte(logoB64))
buf := bytes.Buffer{}
f.Fuzz(func(t *testing.T, data []byte) {
b := &Base64LineBreaker{out: &buf}
if _, err := b.Write(data); err != nil {
t.Errorf("failed to write to B64LineBreaker: %s", err)
}
})
}