reflection_test.go 281 B

1234567891011121314151617
  1. package reflection
  2. import "testing"
  3. type fake struct {
  4. Name string `json:"name"`
  5. Age int `json:"age"`
  6. }
  7. func TestSetter(t *testing.T) {
  8. dst := &fake{}
  9. ms := map[string]string{"name": "aa", "age": "5"}
  10. Setter(dst, ms)
  11. if dst.Age != 5 {
  12. t.Errorf("setter failed")
  13. }
  14. }