1
0
mirror of https://github.com/stretchr/testify.git synced 2025-04-28 13:59:07 +00:00

assert: fix error reporting when error contains escape sequences

Fixes 
This commit is contained in:
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

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

@ -630,7 +630,7 @@ func TestNoError(t *testing.T) {
}() }()
if err == nil { // err is not nil here! 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") 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! 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") True(t, Error(mockT, err), "Error should pass with empty error interface")