Switch to using bytes.NewBuffer(nil) in tests

Refactored the test code to initialize buffers using bytes.NewBuffer(nil) instead of &bytes.Buffer{}. This change ensures a consistent and idiomatic initialization of byte buffers throughout the test cases.
This commit is contained in:
Winni Neessen 2024-10-23 17:57:09 +02:00
parent 12695385e8
commit 21184e60b9
Signed by: wneessen
GPG key ID: 385AC9889632126E

View file

@ -21,7 +21,7 @@ var (
func TestBase64LineBreaker(t *testing.T) {
t.Run("write, copy and close", func(t *testing.T) {
logoWriter := &bytes.Buffer{}
logoWriter := bytes.NewBuffer(nil)
lineBreaker := &Base64LineBreaker{out: logoWriter}
t.Cleanup(func() {
if err := lineBreaker.Close(); err != nil {
@ -43,7 +43,7 @@ func TestBase64LineBreaker(t *testing.T) {
}
})
logoWriter := &bytes.Buffer{}
logoWriter := bytes.NewBuffer(nil)
lineBreaker := &Base64LineBreaker{out: logoWriter}
t.Cleanup(func() {
if err := lineBreaker.Close(); err != nil {
@ -237,9 +237,9 @@ func FuzzBase64LineBreaker(f *testing.F) {
}
f.Fuzz(func(t *testing.T, data []byte) {
var buffer bytes.Buffer
buffer := bytes.NewBuffer(nil)
lineBreaker := &Base64LineBreaker{
out: &buffer,
out: buffer,
}
base64Encoder := base64.NewEncoder(base64.StdEncoding, lineBreaker)