OLD | NEW |
1 package gocheck | 1 package gocheck |
2 | 2 |
3 import ( | 3 import ( |
4 "fmt" | 4 "fmt" |
5 "strings" | 5 "strings" |
6 "time" | 6 "time" |
7 ) | 7 ) |
8 | 8 |
9 // ----------------------------------------------------------------------- | 9 // ----------------------------------------------------------------------- |
10 // Basic succeeding/failing logic. | 10 // Basic succeeding/failing logic. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 85 |
86 // Log some information into the test error output. The provided arguments | 86 // Log some information into the test error output. The provided arguments |
87 // will be assembled together into a string using fmt.Sprintf(). | 87 // will be assembled together into a string using fmt.Sprintf(). |
88 func (c *C) Logf(format string, args ...interface{}) { | 88 func (c *C) Logf(format string, args ...interface{}) { |
89 c.logf(format, args...) | 89 c.logf(format, args...) |
90 } | 90 } |
91 | 91 |
92 // Output enables *C to be used as a logger in functions that require only | 92 // Output enables *C to be used as a logger in functions that require only |
93 // the minimum interface of *log.Logger. | 93 // the minimum interface of *log.Logger. |
94 func (c *C) Output(calldepth int, s string) error { | 94 func (c *C) Output(calldepth int, s string) error { |
95 » ns := time.Now().Sub(time.Time{}).Nanoseconds() | 95 » d := time.Now().Sub(c.startTime) |
96 » t := float64(ns%100e9) / 1e9 | 96 » msec := d / time.Millisecond |
97 » c.Logf("[LOG] %.05f %s", t, s) | 97 » sec := d / time.Second |
| 98 » min := d / time.Minute |
| 99 |
| 100 » c.Logf("[LOG] %d:%02d.%03d %s", min, sec%60, msec%1000, s) |
98 return nil | 101 return nil |
99 } | 102 } |
100 | 103 |
101 // Log an error into the test error output, and mark the test as failed. | 104 // Log an error into the test error output, and mark the test as failed. |
102 // The provided arguments will be assembled together into a string using | 105 // The provided arguments will be assembled together into a string using |
103 // fmt.Sprint(). | 106 // fmt.Sprint(). |
104 func (c *C) Error(args ...interface{}) { | 107 func (c *C) Error(args ...interface{}) { |
105 c.logCaller(1) | 108 c.logCaller(1) |
106 c.logString(fmt.Sprint("Error: ", fmt.Sprint(args...))) | 109 c.logString(fmt.Sprint("Error: ", fmt.Sprint(args...))) |
107 c.logNewLine() | 110 c.logNewLine() |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 } | 215 } |
213 if error != "" { | 216 if error != "" { |
214 c.logString(error) | 217 c.logString(error) |
215 } | 218 } |
216 c.logNewLine() | 219 c.logNewLine() |
217 c.Fail() | 220 c.Fail() |
218 return false | 221 return false |
219 } | 222 } |
220 return true | 223 return true |
221 } | 224 } |
OLD | NEW |