aboutsummaryrefslogtreecommitdiffstats
path: root/diff/diff_ext_test.go
diff options
context:
space:
mode:
authorAlberto Cortés <alberto@sourced.tech>2015-11-16 03:20:01 +0100
committerAlberto Cortés <alberto@sourced.tech>2015-11-25 11:09:51 +0100
commitd643cea1e8a6d618b2eddfdbed086c7bdf208658 (patch)
treeb862c72ccb674910d24eac2ab424a7fb5ea3f0fb /diff/diff_ext_test.go
parentcaab43e7f4ee10a15b2af826485b688473b34356 (diff)
downloadgo-git-d643cea1e8a6d618b2eddfdbed086c7bdf208658.tar.gz
Blame support for files
This also includes a diff package and revlist package (needed by blame) Some extra packfiles (<1MB) are also included, to be used as fixtures in the tests.
Diffstat (limited to 'diff/diff_ext_test.go')
-rw-r--r--diff/diff_ext_test.go50
1 files changed, 50 insertions, 0 deletions
diff --git a/diff/diff_ext_test.go b/diff/diff_ext_test.go
new file mode 100644
index 0000000..5ab8c7d
--- /dev/null
+++ b/diff/diff_ext_test.go
@@ -0,0 +1,50 @@
+package diff_test
+
+import (
+ "testing"
+
+ . "gopkg.in/check.v1"
+
+ "gopkg.in/src-d/go-git.v2/diff"
+)
+
+func Test(t *testing.T) { TestingT(t) }
+
+type suiteCommon struct{}
+
+var _ = Suite(&suiteCommon{})
+
+var diffTests = [...]struct {
+ src string // the src string to diff
+ dst string // the dst string to diff
+}{
+ // equal inputs
+ {"", ""},
+ {"a", "a"},
+ {"a\n", "a\n"},
+ {"a\nb", "a\nb"},
+ {"a\nb\n", "a\nb\n"},
+ {"a\nb\nc", "a\nb\nc"},
+ {"a\nb\nc\n", "a\nb\nc\n"},
+ // missing '\n'
+ {"", "\n"},
+ {"\n", ""},
+ {"a", "a\n"},
+ {"a\n", "a"},
+ {"a\nb", "a\nb"},
+ {"a\nb\n", "a\nb\n"},
+ {"a\nb\nc", "a\nb\nc"},
+ {"a\nb\nc\n", "a\nb\nc\n"},
+ // generic
+ {"a\nbbbbb\n\tccc\ndd\n\tfffffffff\n", "bbbbb\n\tccc\n\tDD\n\tffff\n"},
+}
+
+func (s *suiteCommon) TestCountLines(c *C) {
+ for i, t := range diffTests {
+ diffs := diff.Do(t.src, t.dst)
+ src := diff.Src(diffs)
+ dst := diff.Dst(diffs)
+ c.Assert(src, Equals, t.src, Commentf("subtest %d, src=%q, dst=%q, bad calculated src", i, t.src, t.dst))
+ c.Assert(dst, Equals, t.dst, Commentf("subtest %d, src=%q, dst=%q, bad calculated dst", i, t.src, t.dst))
+ }
+}