1 Star 0 Fork 122

rainbow / phonedata

forked from xluohome / phonedata 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
phonedata_test.go 1.01 KB
一键复制 编辑 原始数据 按行查看 历史
package phonedata
import (
"fmt"
"testing"
"time"
)
func since(t time.Time) int64 {
return time.Since(t).Nanoseconds()
}
func init() {
Debug()
}
func BenchmarkFindPhone(b *testing.B) {
b.RunParallel(func(p *testing.PB) {
var i = 0
for p.Next() {
i++
_, err := Find(fmt.Sprintf("%s%d%s", "1897", i&10000, "45"))
if err != nil {
b.Fatal(err)
}
}
})
}
func TestFindPhone1(t *testing.T) {
_, err := Find("13580198235123123213213")
if err == nil {
t.Fatal("错误的结果")
}
t.Log(err)
}
func TestFindPhone2(t *testing.T) {
_, err := Find("1300")
if err == nil {
t.Fatal("错误的结果")
}
t.Log(err)
}
func TestFindPhone3(t *testing.T) {
pr, err := Find("1703576")
if err != nil {
t.Fatal(err)
}
t.Log(pr)
}
func TestFindPhone4(t *testing.T) {
_, err := Find("10074872323")
if err == nil {
t.Fatal("错误的结果")
}
t.Log(err)
}
func TestFindPhone5(t *testing.T) {
_, err := Find("afsd32323")
if err == nil {
t.Fatal("错误的结果")
}
t.Log(err)
}
Go
1
https://gitee.com/exinyu/phonedata.git
git@gitee.com:exinyu/phonedata.git
exinyu
phonedata
phonedata
master

搜索帮助