-
Notifications
You must be signed in to change notification settings - Fork 0
/
timesheet_config_test.go
97 lines (94 loc) · 1.98 KB
/
timesheet_config_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
package sheet2inv
import (
"testing"
)
func TestColumns_resolve(t *testing.T) {
type fields struct {
TimeStart string
TimeEnd string
Invoice string
Description string
Issue string
start int
end int
inv int
descr int
issue int
}
tests := []struct {
name string
fields fields
wantErr bool
}{
{"in range",
fields{
TimeStart: "A",
TimeEnd: "B",
Invoice: "C",
Description: "D",
Issue: "Z",
},
false,
},
{"out of range",
fields{
TimeStart: "A",
TimeEnd: "B",
Invoice: "C",
Description: "D",
Issue: "3",
},
true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ci := &Columns{
TimeStart: tt.fields.TimeStart,
TimeEnd: tt.fields.TimeEnd,
Invoice: tt.fields.Invoice,
Description: tt.fields.Description,
Issue: tt.fields.Issue,
start: tt.fields.start,
end: tt.fields.end,
inv: tt.fields.inv,
descr: tt.fields.descr,
issue: tt.fields.issue,
}
if err := ci.resolve(); (err != nil) != tt.wantErr {
t.Errorf("Columns.resolve() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func TestColumns_char2int(t *testing.T) {
type args struct {
char string
}
tests := []struct {
name string
args args
want int
wantPanic bool
}{
{"IN range", args{"A"}, 0, false},
{"IN range", args{"a"}, 0, false},
{"IN range", args{"Z"}, 25, false},
{"IN range", args{"z"}, 25, false},
{"1+ chars", args{"aa"}, 0, false},
{"out of range", args{"5"}, 0, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
defer func() {
if r := recover(); r != nil && !tt.wantPanic {
t.Errorf("unexpected panic: %v", r)
}
}()
c := &Columns{}
if got := c.char2int(tt.args.char); got != tt.want {
t.Errorf("Columns.char2int() = %v, want %v", got, tt.want)
}
})
}
}