-
Notifications
You must be signed in to change notification settings - Fork 0
/
coin_test.go
46 lines (44 loc) · 940 Bytes
/
coin_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
package coin
import (
"testing"
)
func Test_MatchAccountName(t *testing.T) {
for _, tf := range []struct {
pattern string
matches []string
fails []string
}{
{
"ex",
[]string{"Expenses", "Income:Extra", "Investments:Forex:USD"},
[]string{"Fees", "Root"},
},
{
"^ex",
[]string{"Expenses"},
[]string{"Income:Extra", "Investments:Forex:USD"},
},
{
"e::c",
[]string{"Expenses:Travel:CAD", "Expenses:CAD", "Investments:Forex:CAD"},
[]string{"Expenses", "Root"},
},
{
"l::mc$",
[]string{"Liabilities:Credit:MC"},
[]string{"Liabilities:Credit:MC2", "Liabilities:Credit:MC:XX"},
},
} {
rx := ToRegex(tf.pattern)
for _, m := range tf.matches {
if !rx.MatchString(m) {
t.Errorf("%s should match %s\nregexp: %s", tf.pattern, m, rx.String())
}
}
for _, m := range tf.fails {
if rx.MatchString(m) {
t.Errorf("%s should not match %s", tf.pattern, m)
}
}
}
}