1 Star 2 Fork 1

guanguans / id-validator

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
id_validator_basic_test.go 878 Bytes
一键复制 编辑 原始数据 按行查看 历史
package idvalidator
import (
"testing"
)
// go test -v -cover -coverprofile=cover.out
// go tool cover -func=cover.out
// go tool cover -html=cover.out
func TestIsValidBasic(t *testing.T) {
errIds := []string{
"44030819990110", // 号码位数不合法
"440308199902301512", // 出生日期码不合法
"440308199901101513", // 验证码不合法
"610104620932690", // 出生日期码不合法
"11010119900307867X", // 校验位不合法
"TES12345678901 j", // 特殊字符格式不合法
}
for _, id := range errIds {
if IsValidBasic(id) {
t.Errorf("ID must be invalid.: %s", id)
}
}
}
func TestGetInfoBasic(t *testing.T) {
_, e1 := GetBasicInfo("440301197110292910")
if e1 != nil {
t.Errorf("`e1` must be nil.: %v", e1)
}
_, e2 := GetBasicInfo("500154199302305886")
if e2 == nil {
t.Errorf("`e2` must not be nil.: %v", e2)
}
}
Go
1
https://gitee.com/guanguans/id-validator.git
git@gitee.com:guanguans/id-validator.git
guanguans
id-validator
id-validator
main

搜索帮助