1
// These tests verify the test running logic.
10
var benchmarkS = Suite(&BenchmarkS{})
12
type BenchmarkS struct{}
14
func (s *BenchmarkS) TestCountSuite(c *C) {
18
func (s *BenchmarkS) TestBasicTestTiming(c *C) {
19
helper := FixtureHelper{sleepOn: "Test1", sleep: 1000000 * time.Nanosecond}
21
runConf := RunConf{Output: &output, Verbose: true}
22
Run(&helper, &runConf)
24
expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Test1\t0\\.001s\n" +
25
"PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Test2\t0\\.000s\n"
26
c.Assert(output.value, Matches, expected)
29
func (s *BenchmarkS) TestStreamTestTiming(c *C) {
30
helper := FixtureHelper{sleepOn: "SetUpSuite", sleep: 1000000 * time.Nanosecond}
32
runConf := RunConf{Output: &output, Stream: true}
33
Run(&helper, &runConf)
35
expected := "(?s).*\nPASS: check_test\\.go:[0-9]+: FixtureHelper\\.SetUpSuite\t *0\\.001s\n.*"
36
c.Assert(output.value, Matches, expected)
39
func (s *BenchmarkS) TestBenchmark(c *C) {
40
helper := FixtureHelper{sleep: 100000}
45
BenchmarkTime: 10000000,
48
Run(&helper, &runConf)
49
c.Check(helper.calls[0], Equals, "SetUpSuite")
50
c.Check(helper.calls[1], Equals, "SetUpTest")
51
c.Check(helper.calls[2], Equals, "Benchmark1")
52
c.Check(helper.calls[3], Equals, "TearDownTest")
53
c.Check(helper.calls[4], Equals, "SetUpTest")
54
c.Check(helper.calls[5], Equals, "Benchmark1")
55
c.Check(helper.calls[6], Equals, "TearDownTest")
58
expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Benchmark1\t *100\t *[12][0-9]{5} ns/op\n"
59
c.Assert(output.value, Matches, expected)
62
func (s *BenchmarkS) TestBenchmarkBytes(c *C) {
63
helper := FixtureHelper{sleep: 100000}
68
BenchmarkTime: 10000000,
71
Run(&helper, &runConf)
73
expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Benchmark2\t *100\t *[12][0-9]{5} ns/op\t *[4-9]\\.[0-9]{2} MB/s\n"
74
c.Assert(output.value, Matches, expected)
77
func (s *BenchmarkS) TestBenchmarkMem(c *C) {
78
helper := FixtureHelper{sleep: 100000}
84
BenchmarkTime: 10000000,
87
Run(&helper, &runConf)
89
expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Benchmark3\t *100\t *[12][0-9]{5} ns/op\t *[0-9]+ B/op\t *[1-9] allocs/op\n"
90
c.Assert(output.value, Matches, expected)