From 21184e60b94178e3040b3fa07ea04b09e4b491d7 Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Wed, 23 Oct 2024 17:57:09 +0200 Subject: [PATCH] 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. --- b64linebreaker_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/b64linebreaker_test.go b/b64linebreaker_test.go index 9f88c7e..dc08471 100644 --- a/b64linebreaker_test.go +++ b/b64linebreaker_test.go @@ -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)