golang.org/x/exp@v0.0.0-20240506185415-9bf2ced13842/slog/internal/buffer/norace_test.go (about) 1 // Copyright 2022 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build !race 6 7 package buffer 8 9 import "testing" 10 11 func TestAlloc(t *testing.T) { 12 got := int(testing.AllocsPerRun(5, func() { 13 b := New() 14 defer b.Free() 15 b.WriteString("not 1K worth of bytes") 16 })) 17 if got != 0 { 18 t.Errorf("got %d allocs, want 0", got) 19 } 20 }