-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
phone_test.go
58 lines (51 loc) · 1.5 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
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 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")
}
}