mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 03:32:33 +08:00
add unit test
This commit is contained in:
parent
eb04f83f26
commit
053e99a2d1
|
@ -267,3 +267,21 @@ func TestStructure_TextUnmarshaller(t *testing.T) {
|
|||
err = decoder.Decode(rawMap, s)
|
||||
assert.NotNilf(t, err, "should throw error: %#v", s)
|
||||
}
|
||||
|
||||
func TestStructure_Null(t *testing.T) {
|
||||
rawMap := map[string]any{
|
||||
"opt": map[string]any{
|
||||
"bar": nil,
|
||||
},
|
||||
}
|
||||
|
||||
s := struct {
|
||||
Opt struct {
|
||||
Bar string `test:"bar,optional"`
|
||||
} `test:"opt,optional"`
|
||||
}{}
|
||||
|
||||
err := decoder.Decode(rawMap, &s)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, s.Opt.Bar, "")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user