mirror of
https://github.com/danog/blackfriday.git
synced 2024-11-26 20:14:43 +01:00
parent
eebcfd6bbf
commit
2ab1ea34bd
@ -18,6 +18,8 @@ import (
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/pmezard/go-difflib/difflib"
|
||||
)
|
||||
|
||||
type TestParams struct {
|
||||
@ -168,8 +170,7 @@ func doTestsReference(t *testing.T, files []string, flag Extensions) {
|
||||
|
||||
actual := string(runMarkdown(input, params))
|
||||
if actual != expected {
|
||||
t.Errorf("\n [%#v]\nExpected[%#v]\nActual [%#v]",
|
||||
basename+".text", expected, actual)
|
||||
t.Errorf("\n" + doTestDiff(basename, expected, actual))
|
||||
}
|
||||
|
||||
// now test every prefix of every input to check for
|
||||
@ -184,3 +185,14 @@ func doTestsReference(t *testing.T, files []string, flag Extensions) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func doTestDiff(name, expected, actual string) string {
|
||||
d, _ := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{
|
||||
A: difflib.SplitLines(expected),
|
||||
B: difflib.SplitLines(actual),
|
||||
FromFile: "expect: " + name,
|
||||
ToFile: "actual: " + name,
|
||||
Context: 1,
|
||||
})
|
||||
return d
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user