LEFT | RIGHT |
1 // This file contains just a few generic helpers which are used by the | 1 // This file contains just a few generic helpers which are used by the |
2 // other test files. | 2 // other test files. |
3 | 3 |
4 package gocheck_test | 4 package gocheck_test |
5 | 5 |
6 import ( | 6 import ( |
7 "flag" | 7 "flag" |
8 "fmt" | 8 "fmt" |
9 "launchpad.net/gocheck" | 9 "launchpad.net/gocheck" |
10 "os" | 10 "os" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 type SuccessHelper struct{} | 87 type SuccessHelper struct{} |
88 | 88 |
89 func (s *SuccessHelper) TestLogAndSucceed(c *gocheck.C) { | 89 func (s *SuccessHelper) TestLogAndSucceed(c *gocheck.C) { |
90 c.Log("Expected success!") | 90 c.Log("Expected success!") |
91 } | 91 } |
92 | 92 |
93 // ----------------------------------------------------------------------- | 93 // ----------------------------------------------------------------------- |
94 // Helper suite for testing ordering and behavior of fixture. | 94 // Helper suite for testing ordering and behavior of fixture. |
95 | 95 |
96 type FixtureHelper struct { | 96 type FixtureHelper struct { |
97 » calls [64]string | 97 » calls []string |
98 » n int | |
99 panicOn string | 98 panicOn string |
100 skip bool | 99 skip bool |
101 skipOnN int | 100 skipOnN int |
102 sleepOn string | 101 sleepOn string |
103 sleep time.Duration | 102 sleep time.Duration |
104 bytes int64 | 103 bytes int64 |
105 } | 104 } |
106 | 105 |
107 func (s *FixtureHelper) trace(name string, c *gocheck.C) { | 106 func (s *FixtureHelper) trace(name string, c *gocheck.C) { |
108 » n := s.n | 107 » s.calls = append(s.calls, name) |
109 » s.calls[n] = name | |
110 » s.n += 1 | |
111 if name == s.panicOn { | 108 if name == s.panicOn { |
112 panic(name) | 109 panic(name) |
113 } | 110 } |
114 if s.sleep > 0 && s.sleepOn == name { | 111 if s.sleep > 0 && s.sleepOn == name { |
115 time.Sleep(s.sleep) | 112 time.Sleep(s.sleep) |
116 } | 113 } |
117 » if s.skip && s.skipOnN == n { | 114 » if s.skip && s.skipOnN == len(s.calls)-1 { |
118 c.Skip("skipOnN == n") | 115 c.Skip("skipOnN == n") |
119 } | 116 } |
120 } | 117 } |
121 | 118 |
122 func (s *FixtureHelper) SetUpSuite(c *gocheck.C) { | 119 func (s *FixtureHelper) SetUpSuite(c *gocheck.C) { |
123 s.trace("SetUpSuite", c) | 120 s.trace("SetUpSuite", c) |
124 } | 121 } |
125 | 122 |
126 func (s *FixtureHelper) TearDownSuite(c *gocheck.C) { | 123 func (s *FixtureHelper) TearDownSuite(c *gocheck.C) { |
127 s.trace("TearDownSuite", c) | 124 s.trace("TearDownSuite", c) |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 expected.name, result, expected.result) | 187 expected.name, result, expected.result) |
191 } | 188 } |
192 if failed != expected.failed { | 189 if failed != expected.failed { |
193 if failed { | 190 if failed { |
194 c.Errorf("%s has failed when it shouldn't", expected.nam
e) | 191 c.Errorf("%s has failed when it shouldn't", expected.nam
e) |
195 } else { | 192 } else { |
196 c.Errorf("%s has not failed when it should", expected.na
me) | 193 c.Errorf("%s has not failed when it should", expected.na
me) |
197 } | 194 } |
198 } | 195 } |
199 } | 196 } |
LEFT | RIGHT |