mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-15 04:57:07 +08:00
Test for error on Unmarshal
This commit is contained in:
parent
64f4975cd3
commit
9c6df94f7c
@ -529,3 +529,14 @@ func TestMappingArrayWithCustomUnmarshal(t *testing.T) {
|
|||||||
|
|
||||||
assert.EqualValues(t, [2]customUnmarshalParamHex{245, 246}, s.HexArray)
|
assert.EqualValues(t, [2]customUnmarshalParamHex{245, 246}, s.HexArray)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMappingArrayWithUnkownType(t *testing.T) {
|
||||||
|
var s struct {
|
||||||
|
U []customUnmarshalParamHex
|
||||||
|
}
|
||||||
|
err := mappingByPtr(&s, formSource{"U": {"unknown"}}, "form")
|
||||||
|
assert.Error(t, err)
|
||||||
|
|
||||||
|
var expectedError *strconv.NumError
|
||||||
|
assert.ErrorAs(t, err, &expectedError)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user