File: column_test.go

package info (click to toggle)
golang-text 0.0~git20130502-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 92 kB
  • ctags: 44
  • sloc: makefile: 8
file content (90 lines) | stat: -rw-r--r-- 1,551 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package colwriter

import (
	"bytes"
	"testing"
)

var src = `
.git
.gitignore
.godir
Procfile:
README.md
api.go
apps.go
auth.go
darwin.go
data.go
dyno.go:
env.go
git.go
help.go
hkdist
linux.go
ls.go
main.go
plugin.go
run.go
scale.go
ssh.go
tail.go
term
unix.go
update.go
version.go
windows.go
`[1:]

var tests = []struct{
	wid  int
	flag uint
	src  string
	want string
}{
	{80, 0, "", ""},
	{80, 0, src, `
.git       README.md  darwin.go  git.go     ls.go      scale.go   unix.go
.gitignore api.go     data.go    help.go    main.go    ssh.go     update.go
.godir     apps.go    dyno.go:   hkdist     plugin.go  tail.go    version.go
Procfile:  auth.go    env.go     linux.go   run.go     term       windows.go
`[1:]},
	{80, BreakOnColon, src, `
.git       .gitignore .godir

Procfile:
README.md api.go    apps.go   auth.go   darwin.go data.go

dyno.go:
env.go     hkdist     main.go    scale.go   term       version.go
git.go     linux.go   plugin.go  ssh.go     unix.go    windows.go
help.go    ls.go      run.go     tail.go    update.go
`[1:]},
	{20, 0, `
Hello
Γειά σου
안녕
今日は
`[1:], `
Hello    안녕
Γειά σου 今日は
`[1:]},
}

func TestWriter(t *testing.T) {
	for _, test := range tests {
		b := new(bytes.Buffer)
		w := NewWriter(b, test.wid, test.flag)
		if _, err := w.Write([]byte(test.src)); err != nil {
			t.Error(err)
		}
		if err := w.Flush(); err != nil {
			t.Error(err)
		}
		if g := b.String(); test.want != g {
			t.Log("\n" + test.want)
			t.Log("\n" + g)
			t.Errorf("%q != %q", test.want, g)
		}
	}
}