diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2015-12-11 23:58:00 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2015-12-11 23:58:00 +0100 |
commit | c22c181f70e0afb294513315e9975b9f3f4c1d39 (patch) | |
tree | 8377ae4645c58454d0f2a61631a4a81d2d7d5faf /common_test.go | |
parent | 5c8fff7e9e614d9f463d964699539fe71509ba39 (diff) | |
parent | c347e978b52212b5aa968a14d81c8fff47ab24d7 (diff) | |
download | go-git-c22c181f70e0afb294513315e9975b9f3f4c1d39.tar.gz |
Merge pull request #7 from alcortesm/blame
Blame
Diffstat (limited to 'common_test.go')
-rw-r--r-- | common_test.go | 29 |
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)) + } +} |