mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-03-06 14:17:32 +00:00
chore: structure support remain-tagged field
This commit is contained in:
@@ -160,6 +160,28 @@ func TestStructure_DoubleNest(t *testing.T) {
|
||||
assert.Equal(t, s.Bar.BazOptional, goal)
|
||||
}
|
||||
|
||||
func TestStructure_Remain(t *testing.T) {
|
||||
rawMap := map[string]any{
|
||||
"foo": 1,
|
||||
"bar": "test",
|
||||
"extra": false,
|
||||
}
|
||||
|
||||
goal := &Baz{
|
||||
Foo: 1,
|
||||
Bar: "test",
|
||||
}
|
||||
|
||||
s := &struct {
|
||||
Baz
|
||||
Remain map[string]any `test:",remain"`
|
||||
}{}
|
||||
err := decoder.Decode(rawMap, s)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, *goal, s.Baz)
|
||||
assert.Equal(t, map[string]any{"extra": false}, s.Remain)
|
||||
}
|
||||
|
||||
func TestStructure_SliceNilValue(t *testing.T) {
|
||||
rawMap := map[string]any{
|
||||
"foo": 1,
|
||||
|
||||
Reference in New Issue
Block a user