-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpayment_test.go
More file actions
212 lines (179 loc) · 3.65 KB
/
payment_test.go
File metadata and controls
212 lines (179 loc) · 3.65 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
package gofaker
import (
"fmt"
"testing"
)
func ExampleCurrency() {
Seed(11)
currency := Currency()
fmt.Printf("%s - %s", currency.Short, currency.Long)
// Output: IQD - Iraq Dinar
}
func BenchmarkCurrency(b *testing.B) {
for i := 0; i < b.N; i++ {
Currency()
}
}
func ExampleCurrencyShort() {
Seed(11)
fmt.Println(CurrencyShort())
// Output: IQD
}
func BenchmarkCurrencyShort(b *testing.B) {
for i := 0; i < b.N; i++ {
CurrencyShort()
}
}
func ExampleCurrencyLong() {
Seed(11)
fmt.Println(CurrencyLong())
// Output: Iraq Dinar
}
func BenchmarkCurrencyLong(b *testing.B) {
for i := 0; i < b.N; i++ {
CurrencyLong()
}
}
func ExamplePrice() {
Seed(11)
fmt.Printf("%.2f", Price(0.8618, 1000))
// Output: 92.26
}
func BenchmarkPrice(b *testing.B) {
for i := 0; i < b.N; i++ {
Price(0, 1000)
}
}
func ExampleCreditCard() {
Seed(11)
ccInfo := CreditCard()
fmt.Println(ccInfo.Type)
fmt.Println(ccInfo.Number)
fmt.Println(ccInfo.Exp)
fmt.Println(ccInfo.Cvv)
// Output:
// UnionPay
// 4645994899536906358
// 11/21
// 259
}
func BenchmarkCreditCard(b *testing.B) {
for i := 0; i < b.N; i++ {
CreditCard()
}
}
func ExampleCreditCardType() {
Seed(11)
fmt.Println(CreditCardType())
// Output: Visa
}
func BenchmarkCreditCardType(b *testing.B) {
for i := 0; i < b.N; i++ {
CreditCardType()
}
}
func ExampleCreditCardNumber() {
Seed(11)
fmt.Println(CreditCardNumber(nil))
fmt.Println(CreditCardNumber(&CreditCardOptions{Types: []string{"visa", "discover"}}))
fmt.Println(CreditCardNumber(&CreditCardOptions{Bins: []string{"4111"}}))
fmt.Println(CreditCardNumber(&CreditCardOptions{Gaps: true}))
// Output:
// 4364599489953690649
// 6011425914583029
// 4111020276132178
// 2131 0889 9822 7212
}
func TestCreditCardNumber(t *testing.T) {
for i := 0; i < 100000; i++ {
if !isLuhn(CreditCardNumber(nil)) {
t.Error("Number was not luhn")
}
}
}
func TestCreditCardNumberLookup(t *testing.T) {
info := GetFuncLookup("creditcardnumber")
m := map[string][]string{
"gaps": {"true"},
}
_, err := info.Call(&m, info)
if err != nil {
t.Fatal(err.Error())
}
// t.Fatal(fmt.Sprintf("%s", value.(string)))
}
func BenchmarkCreditCardNumber(b *testing.B) {
for i := 0; i < b.N; i++ {
CreditCardNumber(nil)
}
}
func TestIsLuhn(t *testing.T) {
// Lets make sure this card is invalid
if isLuhn("867gfsd5309") {
t.Error("Card should have failed")
}
// Lets make sure this card is valid
if !isLuhn("4716685826369360") {
t.Error("Card should not have failed")
}
}
func ExampleCreditCardExp() {
Seed(11)
fmt.Println(CreditCardExp())
// Output: 01/22
}
func BenchmarkCreditCardExp(b *testing.B) {
for i := 0; i < b.N; i++ {
CreditCardExp()
}
}
func ExampleCreditCardCvv() {
Seed(11)
fmt.Println(CreditCardCvv())
// Output: 513
}
func BenchmarkCreditCardCvv(b *testing.B) {
for i := 0; i < b.N; i++ {
CreditCardCvv()
}
}
func ExampleAchRouting() {
Seed(11)
fmt.Println(AchRouting())
// Output: 713645994
}
func BenchmarkAchRouting(b *testing.B) {
for i := 0; i < b.N; i++ {
AchRouting()
}
}
func ExampleAchAccount() {
Seed(11)
fmt.Println(AchAccount())
// Output: 413645994899
}
func BenchmarkAchAccount(b *testing.B) {
for i := 0; i < b.N; i++ {
AchAccount()
}
}
func ExampleBitcoinAddress() {
Seed(11)
fmt.Println(BitcoinAddress())
// Output: 1lWLbxojXq6BqWX7X60VkcDIvYA
}
func BenchmarkBitcoinAddress(b *testing.B) {
for i := 0; i < b.N; i++ {
BitcoinAddress()
}
}
func ExampleBitcoinPrivateKey() {
Seed(11)
fmt.Println(BitcoinPrivateKey())
// Output: 5vrbXTADWJ6sQBSYd6lLkG97jljNc0X9VPBvbVqsIH9lWOLcoqg
}
func BenchmarkBitcoinPrivateKey(b *testing.B) {
for i := 0; i < b.N; i++ {
BitcoinPrivateKey()
}
}