1 // Copyright 2014 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.
11 var allocsPerRunTests
= []struct {
16 {"alloc *byte", func() { global
= new(*byte) }, 1},
17 {"alloc complex128", func() { global
= new(complex128
) }, 1},
18 {"alloc float64", func() { global
= new(float64) }, 1},
19 {"alloc int32", func() { global
= new(int32) }, 1},
20 {"alloc byte", func() { global
= new(byte) }, 1},
23 func TestAllocsPerRun(t
*testing
.T
) {
24 for _
, tt
:= range allocsPerRunTests
{
25 if allocs
:= testing
.AllocsPerRun(100, tt
.fn
); allocs
!= tt
.allocs
{
26 t
.Errorf("AllocsPerRun(100, %s) = %v, want %v", tt
.name
, allocs
, tt
.allocs
)