-
Notifications
You must be signed in to change notification settings - Fork 0
/
idxn_test.go
82 lines (72 loc) · 1.04 KB
/
idxn_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
package idxn_test
import (
"fmt"
"testing"
idx "github.com/Mobilpadde/idxn"
)
func TestAlpha(t *testing.T) {
var tests = []struct {
idx int
len int
want string
}{
{
idx: 0,
want: "a",
},
{
idx: 8,
want: "i",
},
{
idx: 100,
want: "wabc",
},
{
idx: 250,
want: "qabcdefghi",
},
}
for _, tt := range tests {
name := fmt.Sprintf(`%d_%s`, tt.idx, tt.want)
t.Run(name, func(t *testing.T) {
ans := idx.Alpha(tt.idx)
if ans != tt.want {
t.Errorf(`got "%s", want "%s"`, ans, tt.want)
}
})
}
}
func TestAlphanumeric(t *testing.T) {
var tests = []struct {
idx int
len int
want string
}{
{
idx: 0,
want: "a",
},
{
idx: 8,
want: "i",
},
{
idx: 100,
want: "3ab",
},
{
idx: 250,
want: "9abcdef",
},
}
for _, tt := range tests {
name := fmt.Sprintf(`%d_%s`, tt.idx, tt.want)
t.Run(name, func(t *testing.T) {
ans := idx.Alphanumeric(tt.idx)
if ans != tt.want {
t.Errorf(`got "%s", want "%s"`, ans, tt.want)
}
})
}
}