(t *testing.T)
| 386 | } |
| 387 | |
| 388 | func TestPtrFields(t *testing.T) { |
| 389 | m := NewMapperTagFunc("db", strings.ToLower, nil) |
| 390 | type Asset struct { |
| 391 | Title string |
| 392 | } |
| 393 | type Post struct { |
| 394 | *Asset `db:"asset"` |
| 395 | Author string |
| 396 | } |
| 397 | |
| 398 | post := &Post{Author: "Joe", Asset: &Asset{Title: "Hiyo"}} |
| 399 | pv := reflect.ValueOf(post) |
| 400 | |
| 401 | fields := m.TypeMap(reflect.TypeOf(post)) |
| 402 | if len(fields.Index) != 3 { |
| 403 | t.Errorf("Expecting 3 fields") |
| 404 | } |
| 405 | |
| 406 | v := m.FieldByName(pv, "asset.title") |
| 407 | if v.Interface().(string) != post.Asset.Title { |
| 408 | t.Errorf("Expecting %s, got %s", post.Asset.Title, v.Interface().(string)) |
| 409 | } |
| 410 | v = m.FieldByName(pv, "author") |
| 411 | if v.Interface().(string) != post.Author { |
| 412 | t.Errorf("Expecting %s, got %s", post.Author, v.Interface().(string)) |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | func TestNamedPtrFields(t *testing.T) { |
| 417 | m := NewMapperTagFunc("db", strings.ToLower, nil) |
nothing calls this directly
no test coverage detected