diff options
author | Unknwon <u@gogs.io> | 2019-10-23 23:03:17 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-23 23:03:17 -0700 |
commit | 613139e7bef81d3573e7988a47eb6765f3de347a (patch) | |
tree | 49de7277898d3ff47a122c072568edb8ed4c9ac9 /vendor/github.com/smartystreets/assertions/equality_diff.go | |
parent | fb100dbf98f02e4c631d142ff0f52ec29ee2f00c (diff) |
Enable Go modules (#5835)
* Remove vendor
* Enable Go modules
* ci: add command to fetch dependencies
* ci: update setting
* ci: update settings
* Require Go 1.11
* Rename module name to gogs.io/gogs
Diffstat (limited to 'vendor/github.com/smartystreets/assertions/equality_diff.go')
-rw-r--r-- | vendor/github.com/smartystreets/assertions/equality_diff.go | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/vendor/github.com/smartystreets/assertions/equality_diff.go b/vendor/github.com/smartystreets/assertions/equality_diff.go deleted file mode 100644 index bd698ff6..00000000 --- a/vendor/github.com/smartystreets/assertions/equality_diff.go +++ /dev/null @@ -1,37 +0,0 @@ -package assertions - -import ( - "fmt" - - "github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch" -) - -func composePrettyDiff(expected, actual string) string { - diff := diffmatchpatch.New() - diffs := diff.DiffMain(expected, actual, false) - if prettyDiffIsLikelyToBeHelpful(diffs) { - return fmt.Sprintf("\nDiff: '%s'", diff.DiffPrettyText(diffs)) - } - return "" -} - -// prettyDiffIsLikelyToBeHelpful returns true if the diff listing contains -// more 'equal' segments than 'deleted'/'inserted' segments. -func prettyDiffIsLikelyToBeHelpful(diffs []diffmatchpatch.Diff) bool { - equal, deleted, inserted := measureDiffTypeLengths(diffs) - return equal > deleted && equal > inserted -} - -func measureDiffTypeLengths(diffs []diffmatchpatch.Diff) (equal, deleted, inserted int) { - for _, segment := range diffs { - switch segment.Type { - case diffmatchpatch.DiffEqual: - equal += len(segment.Text) - case diffmatchpatch.DiffDelete: - deleted += len(segment.Text) - case diffmatchpatch.DiffInsert: - inserted += len(segment.Text) - } - } - return equal, deleted, inserted -} |