all repos — grayfriday @ 2ab1ea34bddcd35ff0e99c25ff8b169ef5777cb4

blackfriday fork with a few changes

Print diffs for reference tests (#481)

Fixes #469
Cameron Moore moorereason@gmail.com
Tue, 04 Sep 2018 16:36:14 -0500
commit

2ab1ea34bddcd35ff0e99c25ff8b169ef5777cb4

parent

eebcfd6bbfd34db19c08694915b15fca4c473210

1 files changed, 14 insertions(+), 2 deletions(-)

jump to
M helpers_test.gohelpers_test.go

@@ -18,6 +18,8 @@ "io/ioutil"

"path/filepath" "regexp" "testing" + + "github.com/pmezard/go-difflib/difflib" ) type TestParams struct {

@@ -168,8 +170,7 @@ expected := string(expectedBytes)

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 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 +}