Add unit test for ValidateIp4Address
This commit is contained in:
parent
3cd9b2aadf
commit
5a9cf7e754
1 changed files with 24 additions and 0 deletions
24
opts_unit_test.go
Normal file
24
opts_unit_test.go
Normal file
|
@ -0,0 +1,24 @@
|
|||
package docker
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestValidateIP4(t *testing.T) {
|
||||
if ret, err := ValidateIp4Address(`1.2.3.4`); err != nil || ret == "" {
|
||||
t.Fatalf("ValidateIp4Address(`1.2.3.4`) got %s %s", ret, err)
|
||||
}
|
||||
|
||||
if ret, err := ValidateIp4Address(`127.0.0.1`); err != nil || ret == "" {
|
||||
t.Fatalf("ValidateIp4Address(`127.0.0.1`) got %s %s", ret, err)
|
||||
}
|
||||
|
||||
if ret, err := ValidateIp4Address(`127`); err == nil || ret != "" {
|
||||
t.Fatalf("ValidateIp4Address(`127`) got %s %s", ret, err)
|
||||
}
|
||||
|
||||
if ret, err := ValidateIp4Address(`random invalid string`); err == nil || ret != "" {
|
||||
t.Fatalf("ValidateIp4Address(`random invalid string`) got %s %s", ret, err)
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue