Remove dep on umaintained difflib (#515)
Sam Whited sam@samwhited.com
Mon, 21 Jan 2019 08:05:15 +0000
3 files changed,
19 insertions(+),
13 deletions(-)
D
go.sum
@@ -1,2 +0,0 @@
-github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
M
helpers_test.go
→
helpers_test.go
@@ -14,12 +14,12 @@
package blackfriday import ( + "fmt" "io/ioutil" "path/filepath" "regexp" + "strings" "testing" - - "github.com/pmezard/go-difflib/difflib" ) type TestParams struct {@@ -187,12 +187,22 @@ })
} 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, - }) + expectedLines := strings.Split(expected, "\n") + actualLines := strings.Split(actual, "\n") + d := "file: " + name + "\n" + for i, line := range expectedLines { + // Allow the actualLines indexing to panic because we're in tests where + // that's okay and we probably want to know about it if this input is wrong + // somehow. + if line != actualLines[i] { + d += fmt.Sprintf(` +line: %d + +-%s ++%s +`, i, line, actualLines[i]) + } + } + return d }