Add ToURLE tests
This commit is contained in:
parent
ff7c360a3e
commit
2dd4a14d2f
28
cast_test.go
28
cast_test.go
@ -1285,3 +1285,31 @@ func TestToDurationE(t *testing.T) {
|
|||||||
assert.Equal(t, test.expect, v, errmsg)
|
assert.Equal(t, test.expect, v, errmsg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestToURLE(t *testing.T) {
|
||||||
|
type args struct {
|
||||||
|
i interface{}
|
||||||
|
}
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
args args
|
||||||
|
wantU *url.URL
|
||||||
|
wantErr bool
|
||||||
|
}{
|
||||||
|
{"url", args{&url.URL{Scheme: "https", Host: "example.net", Path: "/"}}, &url.URL{Scheme: "https", Host: "example.net", Path: "/"}, false},
|
||||||
|
{"string", args{string("https://example.net/")}, &url.URL{Scheme: "https", Host: "example.net", Path: "/"}, false},
|
||||||
|
{"invalid", args{int(100)}, nil, true},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
gotU, err := ToURLE(tt.args.i)
|
||||||
|
if (err != nil) != tt.wantErr {
|
||||||
|
t.Errorf("ToURLE() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(gotU, tt.wantU) {
|
||||||
|
t.Errorf("ToURLE() = %v, want %v", gotU, tt.wantU)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user