mirror of https://github.com/spf13/cast.git
parent
4d07383ffe
commit
bee9d22b75
|
@ -37,6 +37,7 @@ func TestToString(t *testing.T) {
|
||||||
assert.Equal(t, ToString(8.12), "8.12")
|
assert.Equal(t, ToString(8.12), "8.12")
|
||||||
assert.Equal(t, ToString([]byte("one time")), "one time")
|
assert.Equal(t, ToString([]byte("one time")), "one time")
|
||||||
assert.Equal(t, ToString(template.HTML("one time")), "one time")
|
assert.Equal(t, ToString(template.HTML("one time")), "one time")
|
||||||
|
assert.Equal(t, ToString(template.URL("http://somehost.foo")), "http://somehost.foo")
|
||||||
assert.Equal(t, ToString(foo), "one more time")
|
assert.Equal(t, ToString(foo), "one more time")
|
||||||
assert.Equal(t, ToString(nil), "")
|
assert.Equal(t, ToString(nil), "")
|
||||||
}
|
}
|
||||||
|
|
2
caste.go
2
caste.go
|
@ -194,6 +194,8 @@ func ToStringE(i interface{}) (string, error) {
|
||||||
return string(s), nil
|
return string(s), nil
|
||||||
case template.HTML:
|
case template.HTML:
|
||||||
return string(s), nil
|
return string(s), nil
|
||||||
|
case template.URL:
|
||||||
|
return string(s), nil
|
||||||
case nil:
|
case nil:
|
||||||
return "", nil
|
return "", nil
|
||||||
case fmt.Stringer:
|
case fmt.Stringer:
|
||||||
|
|
Loading…
Reference in New Issue