forked from martinohansen/ynabber
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathynabber_test.go
73 lines (65 loc) · 1.49 KB
/
ynabber_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
package ynabber
import (
"testing"
)
func TestMilliunitsFromAmount(t *testing.T) {
want := Milliunits(123930)
got := MilliunitsFromAmount(123.93)
if want != got {
t.Fatalf("period separated: %s != %s", want, got)
}
want = Milliunits(4924340)
got = MilliunitsFromAmount(4924.34)
if want != got {
t.Fatalf("comma separated: %s != %s", want, got)
}
want = Milliunits(-2990)
got = MilliunitsFromAmount(-2.99)
if want != got {
t.Fatalf("negative amount: %s != %s", want, got)
}
want = Milliunits(-3899000)
got = MilliunitsFromAmount(-3899)
if want != got {
t.Fatalf("amount with no separator: %s != %s", want, got)
}
want = Milliunits(328180)
got = MilliunitsFromAmount(328.18)
if want != got {
t.Fatalf("amount with no separator: %s != %s", want, got)
}
want = Milliunits(32818000)
got = MilliunitsFromAmount(32818)
if want != got {
t.Fatalf("amount with no separator: %s != %s", want, got)
}
}
func TestPayee_Strip(t *testing.T) {
type args struct {
s []string
}
tests := []struct {
name string
p Payee
args args
want Payee
}{
{name: "single",
p: Payee("Im not here"),
args: args{s: []string{"not "}},
want: "Im here",
},
{name: "multiple",
p: Payee("Im not really here"),
args: args{s: []string{"not ", "really "}},
want: "Im here",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.p.Strip(tt.args.s); got != tt.want {
t.Errorf("Payee.Strip() = %v, want %v", got, tt.want)
}
})
}
}