aboutsummaryrefslogtreecommitdiffstats
path: root/common_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'common_test.go')
-rw-r--r--common_test.go29
1 files changed, 28 insertions, 1 deletions
diff --git a/common_test.go b/common_test.go
index cf4fc29..4c48419 100644
--- a/common_test.go
+++ b/common_test.go
@@ -5,9 +5,10 @@ import (
"os"
"testing"
- . "gopkg.in/check.v1"
"gopkg.in/src-d/go-git.v2/clients/common"
"gopkg.in/src-d/go-git.v2/core"
+
+ . "gopkg.in/check.v1"
)
func Test(t *testing.T) { TestingT(t) }
@@ -42,3 +43,29 @@ func (s *MockGitUploadPackService) Fetch(*common.GitUploadPackRequest) (io.ReadC
r, _ := os.Open("formats/packfile/fixtures/git-fixture.ref-delta")
return r, nil
}
+
+type SuiteCommon struct{}
+
+var _ = Suite(&SuiteCommon{})
+
+var countLinesTests = [...]struct {
+ i string // the string we want to count lines from
+ e int // the expected number of lines in i
+}{
+ {"", 0},
+ {"a", 1},
+ {"a\n", 1},
+ {"a\nb", 2},
+ {"a\nb\n", 2},
+ {"a\nb\nc", 3},
+ {"a\nb\nc\n", 3},
+ {"a\n\n\nb\n", 4},
+ {"first line\n\tsecond line\nthird line\n", 3},
+}
+
+func (s *SuiteCommon) TestCountLines(c *C) {
+ for i, t := range countLinesTests {
+ o := CountLines(t.i)
+ c.Assert(o, Equals, t.e, Commentf("subtest %d, input=%q", i, t.i))
+ }
+}