assert: fix error reporting when error contains escape sequences

Fixes #325
pull/443/head
Cameron Moore 2017-03-15 23:11:53 -05:00 committed by Davide D'Agostino
parent 5c861cc4a4
commit 09f61d78b8
2 changed files with 5 additions and 5 deletions

View File

@ -189,7 +189,7 @@ func indentMessageLines(message string, longestLabelLen int) string {
// no need to align first line because it starts at the correct location (after the label)
if i != 0 {
// append alignLen+1 spaces to align with "{{longestLabel}}:" before adding tab
outBuf.WriteString("\n\r\t" + strings.Repeat(" ", longestLabelLen +1) + "\t")
outBuf.WriteString("\n\r\t" + strings.Repeat(" ", longestLabelLen+1) + "\t")
}
outBuf.WriteString(scanner.Text())
}
@ -231,13 +231,13 @@ func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) bool {
content = append(content, labeledContent{"Messages", message})
}
t.Errorf("\r" + getWhitespaceString() + labeledOutput(content...))
t.Errorf("%s", "\r"+getWhitespaceString()+labeledOutput(content...))
return false
}
type labeledContent struct {
label string
label string
content string
}

View File

@ -630,7 +630,7 @@ func TestNoError(t *testing.T) {
}()
if err == nil { // err is not nil here!
t.Errorf("Error should be nil due to empty interface", err)
t.Error("Error should be nil due to empty interface", err)
}
False(t, NoError(mockT, err), "NoError should fail with empty error interface")
@ -664,7 +664,7 @@ func TestError(t *testing.T) {
}()
if err == nil { // err is not nil here!
t.Errorf("Error should be nil due to empty interface", err)
t.Error("Error should be nil due to empty interface", err)
}
True(t, Error(mockT, err), "Error should pass with empty error interface")