1 Star 2 Fork 1

guanguans / id-validator

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
feature_test.go 1.06 KB
一键复制 编辑 原始数据 按行查看 历史
yaozm 提交于 2022-03-04 11:03 . Update tests
// This file is part of the guanguans/id-validator.
// (c) guanguans <ityaozm@gmail.com>
// This source file is subject to the MIT license that is bundled.
package idvalidator
import "testing"
// go test -v -cover -coverprofile=cover.out
// go tool cover -func=cover.out
// go tool cover -html=cover.out
func TestFeature(t *testing.T) {
for i := 0; i < 100; i++ {
if got1 := IsValid(FakeId(), false); !got1 {
t.Errorf("`got1` must be true.: %v", got1)
}
if got2 := IsValid(FakeRequireId(true, "江苏省", "200001", 1), false); !got2 {
t.Errorf("`got2` must be true.: %v", got2)
}
if _, e1 := GetInfo(FakeId(), false); e1 != nil {
t.Errorf("`e1` must be nil.: %v", e1)
}
if _, e2 := GetInfo(FakeRequireId(true, "江苏省", "200001", 1), false); e2 != nil {
t.Errorf("`e2` must be nil.: %v", e2)
}
// id, e3 := UpgradeId(FakeRequireId(false, "", "", 0))
id, e3 := UpgradeId("610104620927690")
if e3 != nil {
t.Errorf("`e3` must be nil.: %v", e3)
}
if l := len(id); l != 18 {
t.Errorf("`id` of length must be 18.: %d", l)
}
}
}
Go
1
https://gitee.com/guanguans/id-validator.git
git@gitee.com:guanguans/id-validator.git
guanguans
id-validator
id-validator
main

搜索帮助

53164aa7 5694891 3bd8fe86 5694891