golang.org/x/exp@v0.0.0-20240506185415-9bf2ced13842/slog/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 slog
     8  
     9  import "testing"
    10  
    11  func wantAllocs(t *testing.T, want int, f func()) {
    12  	t.Helper()
    13  	got := int(testing.AllocsPerRun(5, f))
    14  	if got != want {
    15  		t.Errorf("got %d allocs, want %d", got, want)
    16  	}
    17  }