forked from bxcodec/faker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
phone_test.go
62 lines (54 loc) · 1.56 KB
/
phone_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
package faker
import (
"reflect"
"strings"
"testing"
)
func TestPhoneNumber(t *testing.T) {
ph, err := GetPhoner().PhoneNumber(reflect.Value{})
if err != nil {
t.Error("Expected not error, got err", err)
}
if strings.Count(ph.(string), "-") != 2 {
t.Error("Expected no more than two characters '-'")
}
}
func TestTollFreePhoneNumber(t *testing.T) {
ph, err := GetPhoner().TollFreePhoneNumber(reflect.Value{})
if err != nil {
t.Error("Expected not error, got err", err)
}
if !strings.HasPrefix(ph.(string), "(888)") && !strings.HasPrefix(ph.(string), "(777)") {
t.Error("Expected character '(888)' or (777), in function TollFreePhoneNumber")
}
}
func TestE164PhoneNumber(t *testing.T) {
ph, err := GetPhoner().E164PhoneNumber(reflect.Value{})
if err != nil {
t.Error("Expected not error, got err", err)
}
if !strings.HasPrefix(ph.(string), "+") {
t.Error("Expected character '(888)', in function TollFreePhoneNumber")
}
}
func TestSetPhoner(t *testing.T) {
SetPhoner(Phone{})
}
func TestFakePhoneNumber(t *testing.T) {
ph := Phonenumber()
if strings.Count(ph, "-") != 2 {
t.Error("Expected no more than two characters '-'")
}
}
func TestFakeTollFreePhoneNumber(t *testing.T) {
ph := TollFreePhoneNumber()
if !strings.HasPrefix(ph, "(888)") && !strings.HasPrefix(ph, "(777)") {
t.Error("Expected character '(888)' or (777), in function TollFreePhoneNumber")
}
}
func TestFakeE164PhoneNumber(t *testing.T) {
ph := E164PhoneNumber()
if !strings.HasPrefix(ph, "+") {
t.Error("Expected character '(888)', in function TollFreePhoneNumber")
}
}