phone number, plus other changes

master
Charles Iliya Krempeaux 2021-11-20 17:46:15 -08:00
parent 69d97404f4
commit bf91198da0
10 changed files with 73 additions and 0 deletions

View File

@ -9,10 +9,16 @@ var (
Default = New( rand.NewSource( time.Now().UTC().UnixNano() ) )
)
// Bool returns an arbitrary bool.
func Bool() bool {
return Default.Bool()
}
// PhoneNumber returns an arbitrary phonenumber.
func PhoneNumber() string {
return Default.PhoneNumber()
}
func Runes(a ...interface{}) []rune {
return Default.Runes(a...)
}

View File

View File

6
t_phonenumber.go 100644
View File

@ -0,0 +1,6 @@
package arbitrary
// PhoneNumber returns an arbitrary phonenumber.
func (arb T) PhoneNumber() string {
return arb.phonenumber_canada()
}

View File

@ -0,0 +1,61 @@
package arbitrary
import (
"fmt"
)
func (arb T) phonenumber_canada() string {
var areacode string
{
var areacodes []string = []string{
"604",
"250",
"778",
"236",
"672",
}
areacode = areacodes[arb.randomness.Intn(len(areacodes))]
}
var localpart1 string
{
localpart1 = fmt.Sprint(arb.randomness.Intn(1000))
}
var localpart2 string
{
localpart2 = fmt.Sprint(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",
}
format = formats[arb.randomness.Intn(len(formats))]
}
var result string
{
fmt.Sprintf(format, areacode, localpart1, localpart2)
}
return result
}