-
Notifications
You must be signed in to change notification settings - Fork 1
/
catalog_test.go
48 lines (45 loc) · 850 Bytes
/
catalog_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
package main
import (
"reflect"
"testing"
)
func TestFindDashes(t *testing.T) {
for _, pair := range []struct {
s string
e []int
}{
{"", nil},
{"eeeeeeeee", nil},
{"asdf-eeeeee", []int{4}},
{"asdf--eeeee", []int{4, 5}},
{"-tttttt", []int{0}},
{"---oooooo", []int{0, 1, 2}},
{"qqqqqq-", []int{6}},
{"qqqqqq--", []int{6, 7}},
{"qqqqqq---", []int{6, 7, 8}},
{"-a-b--cdef-", []int{0, 2, 4, 5, 10}},
} {
if !reflect.DeepEqual(pair.e, findDashes(pair.s)) {
t.Error(pair)
}
}
}
func TestMatchLen(t *testing.T) {
for _, args := range []struct {
a, b string
e int
}{
{"", "", 0},
{"a", "", 0},
{"", "b", 0},
{"b", "b", 1},
{"bcccc", "b", 1},
{"bcccc", "bcc", 3},
{"uiopuiop", "uiopuiop", 8},
{"uiOpuiop", "uiopuiop", 2},
} {
if args.e != matchLen(args.a, args.b) {
t.Error(args)
}
}
}