-
Notifications
You must be signed in to change notification settings - Fork 0
/
screen_mode_test.go
70 lines (67 loc) · 1.53 KB
/
screen_mode_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
package tcg
import "testing"
func Test_checkCharMapping(t *testing.T) {
type args struct {
width int
height int
cm []rune
}
tests := []struct {
name string
args args
wantErr bool
}{
{
name: "all zero",
args: args{width: 0, height: 0, cm: nil},
wantErr: true,
},
{
name: "empty list",
args: args{width: 1, height: 1, cm: nil},
wantErr: true,
},
{
name: "empty list2",
args: args{width: 1, height: 1, cm: []rune{}},
wantErr: true,
},
{
name: "1x1 not valid",
args: args{width: 1, height: 1, cm: []rune{32}},
wantErr: true,
},
{
name: "1x1 valid",
args: args{width: 1, height: 1, cm: []rune{32, 33}},
wantErr: false,
},
{
name: "1x2 not valid",
args: args{width: 1, height: 2, cm: []rune{32}},
wantErr: true,
},
{
name: "1x2 valid",
args: args{width: 1, height: 2, cm: []rune{32, 33, 34, 35}},
wantErr: false,
},
{
name: "2x2 not valid",
args: args{width: 2, height: 2, cm: []rune{32, 33, 34, 35, 32, 33, 34, 35, 32, 33, 34, 35, 32, 33, 34}},
wantErr: true,
},
{
name: "2x2 valid",
args: args{width: 2, height: 2, cm: []rune{32, 33, 34, 35, 32, 33, 34, 35, 32, 33, 34, 35, 32, 33, 34, 35}},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := checkCharMapping(tt.args.width, tt.args.height, tt.args.cm); (err != nil) != tt.wantErr {
t.Errorf("checkCharMapping() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}