Debian Codegraph @

iter_test.go

raw symbols SCIP
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.
4
5 package iter_test
6
7 import (
8 "fmt"
9 "testing"
10
11 "github.com/bradfitz/iter"
12 )
13
14 func ExampleN() {
15 for i := range iter.N(4) {
16 fmt.Println(i)
17 }
18 // Output:
19 // 0
20 // 1
21 // 2
22 // 3
23 }
24
25 func TestAllocs(t *testing.T) {
26 var sink []struct{}
27 allocs := testing.AllocsPerRun(1000, func() {
28 sink = iter.N(1e9)
29 })
30 _ = sink
31 if allocs > 0.1 {
32 t.Errorf("allocs = %v", allocs)
33 }
34 }