fix: should not conflict on lower members (#3095)

This commit is contained in:
Kevin Wan
2023-04-08 14:47:57 +08:00
committed by GitHub
parent 92f2676afc
commit 07f03ebd0c
2 changed files with 22 additions and 0 deletions

View File

@@ -1040,6 +1040,24 @@ func TestLoadNamedFieldOverwritten(t *testing.T) {
})
}
func TestLoadLowerMemberShouldNotConflict(t *testing.T) {
type (
Redis struct {
db uint
}
Config struct {
db uint
Redis
}
)
var c Config
assert.NoError(t, LoadFromJsonBytes([]byte(`{}`), &c))
assert.Zero(t, c.db)
assert.Zero(t, c.Redis.db)
}
func TestFillDefaultUnmarshal(t *testing.T) {
t.Run("nil", func(t *testing.T) {
type St struct{}