added ipv4 validation
This commit is contained in:
25
ping/ping_test.go
Normal file
25
ping/ping_test.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package ping
|
||||
|
||||
import "testing"
|
||||
|
||||
func Test_isValidIPv4(t *testing.T) {
|
||||
type args struct {
|
||||
ip string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want bool
|
||||
}{
|
||||
{name: "1", args: args{ip: "192.168.1.1"}, want: true},
|
||||
{name: "2", args: args{ip: "192.168.277.1"}, want: false},
|
||||
{name: "3", args: args{ip: "kurac palac"}, want: false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := isValidIPv4(tt.args.ip); got != tt.want {
|
||||
t.Errorf("isValidIPv4() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user