This repository has been archived by the owner on Feb 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
address_test.go
73 lines (69 loc) · 1.58 KB
/
address_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 sbanken
import "testing"
func TestAddressString(t *testing.T) {
tests := []struct {
name string
addr Address
exp string
}{
{
name: "should handle empty address struct",
addr: Address{},
exp: "",
},
{
name: "should handle partly filled address struct",
addr: Address{
AddressLine1: "Testerstreet 1",
},
exp: "Testerstreet 1",
},
{
name: "should handle partly filled address struct",
addr: Address{
AddressLine2: "Testerstreet 2",
},
exp: "Testerstreet 2",
},
{
name: "should handle partly filled address struct",
addr: Address{
AddressLine1: "Testerstreet 1",
Country: "Norway",
ZipCode: "1337",
City: "Sandvika",
},
exp: "Testerstreet 1, 1337 Sandvika, Norway",
},
{
name: "should handle partly filled address struct",
addr: Address{
AddressLine1: "Testerstreet 1",
Country: "Norway",
City: "Sandvika",
},
exp: "Testerstreet 1, Sandvika, Norway",
},
{
name: "should handle completly filled address struct",
addr: Address{
AddressLine1: "c/o Test Testesen",
AddressLine2: "Testerstreet 1",
AddressLine3: "PO 13371337",
AddressLine4: "Blabla",
Country: "Norway",
ZipCode: "1337",
City: "Sandvika",
},
exp: "c/o Test Testesen, Testerstreet 1, PO 13371337, Blabla, 1337 Sandvika, Norway",
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
addr := tc.addr.String()
if addr != tc.exp {
t.Errorf("unexpected address string: got %s, exp %s", addr, tc.exp)
}
})
}
}