Skip to content

Commit 9d3b2bc

Browse files
committed
Improve test output
1 parent 5011e4c commit 9d3b2bc

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

geezer/geezer_test.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func TestExec(t *testing.T) {
119119
got := runExec(t, test.s, test.w, test.rs)
120120
want := sasa.TrimMargin(test.want)
121121
if got != want {
122-
t.Errorf("got=%v, want=%v", got, want)
122+
t.Errorf("\ngot:\n%v\nwant:\n%v", formatExecOutput(got), formatExecOutput(want))
123123
}
124124
})
125125
}
@@ -134,3 +134,17 @@ func runExec(t *testing.T, s string, indentWidth int, withSpaceRunes []rune) str
134134
}
135135
return w.String()
136136
}
137+
138+
func formatExecOutput(s string) string {
139+
lines := strings.Split(s, "\n")
140+
for i := range lines {
141+
lines[i] = replacePrefixAndSuffix(lines[i], " ", "␣")
142+
}
143+
return strings.Join(lines, "\n")
144+
}
145+
146+
func replacePrefixAndSuffix(s, old, new string) string {
147+
s = sasa.ReplacePrefix(s, old, new)
148+
s = sasa.ReplaceSuffix(s, old, new)
149+
return s
150+
}

0 commit comments

Comments
 (0)