diff --git a/README.md b/README.md index fdd9f26..4d26f4e 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ Example: go get github.com/icza/gowut/gwu go get github.com/udhos/lockfile go get github.com/udhos/equalfile + go get github.com/udhos/difflib go get gopkg.in/yaml.v2 go get golang.org/x/crypto/ssh go get github.com/aws/aws-sdk-go diff --git a/jazigo/ui_test.go b/jazigo/ui_test.go new file mode 100644 index 0000000..3f4ca4e --- /dev/null +++ b/jazigo/ui_test.go @@ -0,0 +1,28 @@ +package main + +import ( + "testing" +) + +func TestSplitBufLines(t *testing.T) { + split(t, "", 0) + split(t, "x", 1) + split(t, "\n", 1) + split(t, "x\n", 1) + split(t, "\nx", 2) + split(t, "x\nx", 2) + split(t, "\n\n", 2) + split(t, "x\n\n", 2) + split(t, "\nx\n", 2) + split(t, "\n\nx", 3) + split(t, "\n\nx\n", 3) + split(t, "\n\n\n", 3) +} + +func split(t *testing.T, input string, wantLineCount int) { + result := splitBufLines([]byte(input)) + count := len(result) + if count != wantLineCount { + t.Errorf("splitBufLines: input=%v expected=%d got=%d", input, wantLineCount, count) + } +}