kos/util/reflection/reflection_test.go

18 lines
281 B
Go
Raw Normal View History

2023-08-16 09:57:42 +08:00
package reflection
import "testing"
type fake struct {
Name string `json:"name"`
Age int `json:"age"`
}
func TestSetter(t *testing.T) {
dst := &fake{}
ms := map[string]string{"name": "aa", "age": "5"}
Setter(dst, ms)
if dst.Age != 5 {
t.Errorf("setter failed")
}
}