Add feature testing
This commit is contained in:
parent
c9d9bc5125
commit
50b81aaf8a
1
.gitignore
vendored
1
.gitignore
vendored
@ -20,3 +20,4 @@
|
||||
.DS_Store
|
||||
.history/
|
||||
tests.go
|
||||
coverage.xml
|
||||
|
@ -76,7 +76,7 @@ func main() {
|
||||
## Testing
|
||||
|
||||
``` bash
|
||||
$ make ...
|
||||
$ go test
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
36
feature_test.go
Normal file
36
feature_test.go
Normal file
@ -0,0 +1,36 @@
|
||||
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) {
|
||||
isValid1 := IsValid(FakeId())
|
||||
if !isValid1 {
|
||||
t.Errorf("`isValid1` must be true.")
|
||||
}
|
||||
|
||||
isValid2 := IsValid(FakeRequireId(true, "江苏省", "200001", 1))
|
||||
if !isValid2 {
|
||||
t.Errorf("`isValid2` must be true.")
|
||||
}
|
||||
|
||||
_, err1 := GetInfo(FakeRequireId(true, "江苏省", "200001", 1))
|
||||
if err1 != nil {
|
||||
t.Errorf("`err1` must be nil.")
|
||||
}
|
||||
|
||||
_, err2 := GetInfo(FakeRequireId(true, "江苏省", "200001", 1))
|
||||
if err2 != nil {
|
||||
t.Errorf("`err2` must be nil.")
|
||||
}
|
||||
|
||||
upgradedId, err3 := UpgradeId("610104620927690")
|
||||
if err3 != nil {
|
||||
t.Errorf("`err3` must be nil.")
|
||||
}
|
||||
if len(upgradedId) != 18 {
|
||||
t.Errorf("`upgradedId` length must be 18.:%d", len(upgradedId))
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user