phone number

master
Charles Iliya Krempeaux 2021-11-21 08:27:42 -08:00
parent 5082385fb5
commit b8ede4166a
2 changed files with 26 additions and 19 deletions

View File

@ -2,5 +2,12 @@ package arbitrary
// PhoneNumber returns an arbitrary phonenumber.
func (arb T) PhoneNumber() string {
return arb.phonenumber_canada()
var funcs []func()string = []func()string{
arb.phonenumber_canada,
}
fn := funcs[arb.randomness.Intn(len(funcs))]
return fn()
}

View File

@ -75,33 +75,33 @@ func (arb T) phonenumber_canada() string {
areacode = areacodes[arb.randomness.Intn(len(areacodes))]
}
var localpart1 string
var localpart1 int
{
localpart1 = fmt.Sprint(arb.randomness.Intn(1000))
localpart1 = arb.randomness.Intn(1000)
}
var localpart2 string
var localpart2 int
{
localpart2 = fmt.Sprint(arb.randomness.Intn(10000))
localpart2 = arb.randomness.Intn(10000)
}
var format string
{
var formats []string = []string{
"%s-%s%s",
"%s-%s-%s",
"%s %s %s",
"%s %s%s",
"(%s) %s%s",
"(%s)%s%s",
"(%s) %s-%s",
"(%s)%s-%s",
"(%s) %s %s",
"(%s)%s %s",
"%s/%s-%s",
"+1%s%s%s",
"+1-%s-%s-%s",
"+1 %s %s %s",
"%s-%03d%04d",
"%s-%03d-%04d",
"%s %03d %04d",
"%s %03d%04d",
"(%s) %03d%04d",
"(%s)%03d%04d",
"(%s) %03d-%04d",
"(%s)%03d-%04d",
"(%s) %03d %04d",
"(%s)%03d %04d",
"%s/%03d-%04d",
"+1%s%03d%04d",
"+1-%s-%03d-%04d",
"+1 %s %03d %04d",
}
format = formats[arb.randomness.Intn(len(formats))]