-
Notifications
You must be signed in to change notification settings - Fork 0
/
a1_test.go
51 lines (48 loc) · 932 Bytes
/
a1_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
package main
import (
"reflect"
"testing"
)
func TestA1ToIndex(t *testing.T) {
tests := []struct {
a1 string
expected int
}{
{"A", 0},
{"B", 1},
{"Z", 25},
{"AA", 26},
{"AB", 27},
{"AZ", 51},
{"AAA", 702},
}
for _, tt := range tests {
t.Run(tt.a1, func(t *testing.T) {
got := A1ToIndex(tt.a1)
if got != tt.expected {
t.Errorf("A1ToIndex(%s) == %d, want %d", tt.a1, got, tt.expected)
}
})
}
}
func TestA1ToIndeces(t *testing.T) {
tests := []struct {
a1 string
expected []int
}{
{"", []int{}},
{"AA", []int{26}},
{"A:C", []int{0, 1, 2}},
{"C:A", []int{2, 1, 0}},
{"A:C,E", []int{0, 1, 2, 4}},
{"A:C,B:D", []int{0, 1, 2, 1, 2, 3}},
}
for _, tt := range tests {
t.Run(tt.a1, func(t *testing.T) {
got := A1ToIndeces(tt.a1)
if !reflect.DeepEqual(got, tt.expected) {
t.Errorf("A1ToIndeces(%s) == %v, want %v", tt.a1, got, tt.expected)
}
})
}
}