-
Notifications
You must be signed in to change notification settings - Fork 0
/
gohr_test.go
98 lines (96 loc) · 1.61 KB
/
gohr_test.go
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
91
92
93
94
95
96
97
98
package gohr
import (
"bytes"
"testing"
)
func Test_drawPatterns(t *testing.T) {
type args struct {
w int
patterns []string
}
tests := []struct {
name string
args args
wantWr string
}{
{
"Default pattern, even width",
args{
w: 4,
patterns: []string{},
},
"####\n",
},
{
"Default pattern, odd width",
args{
w: 3,
patterns: []string{},
},
"###\n",
},
{
"Custom pattern (single character), even width",
args{
w: 4,
patterns: []string{"-"},
},
"----\n",
},
{
"Custom pattern (single character), odd width",
args{
w: 5,
patterns: []string{"-"},
},
"-----\n",
},
{
"Custom pattern (multiple characters), even width",
args{
w: 4,
patterns: []string{"-+"},
},
"-+-+\n",
},
{
"Custom pattern (multiple characters), odd width",
args{
w: 5,
patterns: []string{"-+"},
},
"-+-+-\n",
},
{
"Custom pattern 2 (multiple characters), odd width",
args{
w: 7,
patterns: []string{"-+="},
},
"-+=-+=-\n",
},
{
"Custom patterns, even width",
args{
w: 6,
patterns: []string{"-+", "0"},
},
"-+-+-+\n000000\n",
},
{
"Custom patterns, odd width",
args{
w: 9,
patterns: []string{"//", "\\"},
},
"/////////\n\\\\\\\\\\\\\\\\\\\n",
},
}
for _, tt := range tests {
wr := &bytes.Buffer{}
drawPatterns(tt.args.w, tt.args.patterns, wr)
if gotWr := wr.String(); gotWr != tt.wantWr {
t.Errorf("%q. drawPatterns() = %v, want %v", tt.name, gotWr, tt.wantWr)
}
}
}