Hmm, slice out of range error, wtf x2.

This commit is contained in:
Alex Bramley 2011-10-22 16:42:24 +01:00
parent ebc34cdce5
commit 1df07d2ff6
1 changed files with 3 additions and 3 deletions

View File

@ -57,12 +57,12 @@ func (m writerMap) CheckWrittenAtLevel(t *testing.T, lv LogLevel, exp string) {
} else { } else {
w = m[lv] w = m[lv]
} }
if len(w.written) < 32 { // 32 bytes covers the date, time and filename up to the colon in
// 2011/10/22 10:22:57 log_test.go:<line no>: <level> <log message>
if len(w.written) <= 32 {
t.Errorf("Not enough bytes logged at level %s:", LogString(lv)) t.Errorf("Not enough bytes logged at level %s:", LogString(lv))
t.Errorf("\tgot: %s", string(w.written)) t.Errorf("\tgot: %s", string(w.written))
} }
// 32 bytes covers the date, time and filename up to the colon in
// 2011/10/22 10:22:57 log_test.go:<line no>: <level> <log message>
s := string(w.written[32:]) s := string(w.written[32:])
// 2 covers the : itself and the extra space // 2 covers the : itself and the extra space
idx := strings.Index(s, ":") + 2 idx := strings.Index(s, ":") + 2