* tree-ssa-reassoc.c (reassociate_bb): Clarify code slighly.
[official-gcc.git] / libgo / go / testing / allocs_test.go
blob5b346aaf83873ad5feb5196403abfdf76aa372d4
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.
5 package testing_test
7 import "testing"
9 var global interface{}
11 var allocsPerRunTests = []struct {
12 name string
13 fn func()
14 allocs float64
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)