aboutsummaryrefslogtreecommitdiffstats
path: root/diff
diff options
context:
space:
mode:
authorAlberto Cortés <alberto@sourced.tech>2015-11-27 12:39:34 +0100
committerAlberto Cortés <alberto@sourced.tech>2015-12-04 09:48:41 +0100
commit48bf5bdeb9092ee5004014c0bf7a21f0e2fbf6fc (patch)
treed96d8dfe4c8e4e18f19f2f50d67befc4d9a88d57 /diff
parentd643cea1e8a6d618b2eddfdbed086c7bdf208658 (diff)
downloadgo-git-48bf5bdeb9092ee5004014c0bf7a21f0e2fbf6fc.tar.gz
fix PR#7 comments
Diffstat (limited to 'diff')
-rw-r--r--diff/diff_ext_test.go65
1 files changed, 62 insertions, 3 deletions
diff --git a/diff/diff_ext_test.go b/diff/diff_ext_test.go
index 5ab8c7d..460cf8a 100644
--- a/diff/diff_ext_test.go
+++ b/diff/diff_ext_test.go
@@ -3,9 +3,10 @@ package diff_test
import (
"testing"
- . "gopkg.in/check.v1"
-
"gopkg.in/src-d/go-git.v2/diff"
+
+ "github.com/sergi/go-diff/diffmatchpatch"
+ . "gopkg.in/check.v1"
)
func Test(t *testing.T) { TestingT(t) }
@@ -39,7 +40,7 @@ var diffTests = [...]struct {
{"a\nbbbbb\n\tccc\ndd\n\tfffffffff\n", "bbbbb\n\tccc\n\tDD\n\tffff\n"},
}
-func (s *suiteCommon) TestCountLines(c *C) {
+func (s *suiteCommon) TestAll(c *C) {
for i, t := range diffTests {
diffs := diff.Do(t.src, t.dst)
src := diff.Src(diffs)
@@ -48,3 +49,61 @@ func (s *suiteCommon) TestCountLines(c *C) {
c.Assert(dst, Equals, t.dst, Commentf("subtest %d, src=%q, dst=%q, bad calculated dst", i, t.src, t.dst))
}
}
+
+var doTests = [...]struct {
+ src, dst string
+ expected []diffmatchpatch.Diff
+}{
+ {
+ src: "",
+ dst: "",
+ expected: []diffmatchpatch.Diff{},
+ },
+ {
+ src: "a",
+ dst: "a",
+ expected: []diffmatchpatch.Diff{
+ {
+ Type: 0,
+ Text: "a",
+ },
+ },
+ },
+ {
+ src: "",
+ dst: "abc\ncba",
+ expected: []diffmatchpatch.Diff{
+ {
+ Type: 1,
+ Text: "abc\ncba",
+ },
+ },
+ },
+ {
+ src: "abc\ncba",
+ dst: "",
+ expected: []diffmatchpatch.Diff{
+ {
+ Type: -1,
+ Text: "abc\ncba",
+ },
+ },
+ },
+ {
+ src: "abc\nbcd\ncde",
+ dst: "000\nabc\n111\nBCD\n",
+ expected: []diffmatchpatch.Diff{
+ {Type: 1, Text: "000\n"},
+ {Type: 0, Text: "abc\n"},
+ {Type: -1, Text: "bcd\ncde"},
+ {Type: 1, Text: "111\nBCD\n"},
+ },
+ },
+}
+
+func (s *suiteCommon) TestDo(c *C) {
+ for i, t := range doTests {
+ diffs := diff.Do(t.src, t.dst)
+ c.Assert(diffs, DeepEquals, t.expected, Commentf("subtest %d", i))
+ }
+}