26 lines
543 B
Go
26 lines
543 B
Go
|
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)
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
}
|