mirror of
https://github.com/aclindsa/ofxgo.git
synced 2024-11-22 03:30:04 -05:00
request_test: Point out first difference in marshalled string
This commit is contained in:
parent
3fa614b649
commit
1cbd433116
@ -3,6 +3,7 @@ package ofxgo_test
|
|||||||
import (
|
import (
|
||||||
"github.com/aclindsa/ofxgo"
|
"github.com/aclindsa/ofxgo"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -27,15 +28,21 @@ func marshalCheckRequest(t *testing.T, request *ofxgo.Request, expected string)
|
|||||||
|
|
||||||
for i := 0; i < compareLength; i++ {
|
for i := 0; i < compareLength; i++ {
|
||||||
if expectedString[i] != actualString[i] {
|
if expectedString[i] != actualString[i] {
|
||||||
|
firstDifferencePosition := 13
|
||||||
displayStart := i - 10
|
displayStart := i - 10
|
||||||
|
prefix := "..."
|
||||||
|
suffix := "..."
|
||||||
if displayStart < 0 {
|
if displayStart < 0 {
|
||||||
|
prefix = ""
|
||||||
|
firstDifferencePosition = i
|
||||||
displayStart = 0
|
displayStart = 0
|
||||||
}
|
}
|
||||||
displayEnd := displayStart + 40
|
displayEnd := displayStart + 40
|
||||||
if displayEnd > compareLength {
|
if displayEnd > compareLength {
|
||||||
|
suffix = ""
|
||||||
displayEnd = compareLength
|
displayEnd = compareLength
|
||||||
}
|
}
|
||||||
t.Fatalf("%s expected '...%s...',\ngot '...%s...'\n", t.Name(), expectedString[displayStart:displayEnd], actualString[displayStart:displayEnd])
|
t.Fatalf("%s expected '%s%s%s',\ngot '%s%s%s'\n %s^ first difference\n", t.Name(), prefix, expectedString[displayStart:displayEnd], suffix, prefix, actualString[displayStart:displayEnd], suffix, strings.Repeat(" ", firstDifferencePosition))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user