(t *testing.T)
| 696 | } |
| 697 | |
| 698 | func TestAnonymousStructFields(t *testing.T) { |
| 699 | |
| 700 | type Contact0 string |
| 701 | |
| 702 | type Contact1 struct { |
| 703 | Name string |
| 704 | } |
| 705 | |
| 706 | type Contact2 interface{} |
| 707 | |
| 708 | type Contact3 interface{} |
| 709 | |
| 710 | type Thing struct { |
| 711 | Contact0 |
| 712 | Contact1 |
| 713 | Contact2 |
| 714 | Contact3 |
| 715 | } |
| 716 | |
| 717 | x := Thing{ |
| 718 | Contact0: "hello", |
| 719 | Contact1: Contact1{ |
| 720 | Name: "marty", |
| 721 | }, |
| 722 | Contact2: Contact1{ |
| 723 | Name: "will", |
| 724 | }, |
| 725 | Contact3: "steve", |
| 726 | } |
| 727 | |
| 728 | doc := document.NewDocument("1") |
| 729 | m := NewIndexMapping() |
| 730 | err := m.MapDocument(doc, x) |
| 731 | if err != nil { |
| 732 | t.Fatal(err) |
| 733 | } |
| 734 | |
| 735 | if len(doc.Fields) != 4 { |
| 736 | t.Fatalf("expected 4 fields, got %d", len(doc.Fields)) |
| 737 | } |
| 738 | if doc.Fields[0].Name() != "Contact0" { |
| 739 | t.Errorf("expected field named 'Contact0', got '%s'", doc.Fields[0].Name()) |
| 740 | } |
| 741 | if doc.Fields[1].Name() != "Name" { |
| 742 | t.Errorf("expected field named 'Name', got '%s'", doc.Fields[1].Name()) |
| 743 | } |
| 744 | if doc.Fields[2].Name() != "Contact2.Name" { |
| 745 | t.Errorf("expected field named 'Contact2.Name', got '%s'", doc.Fields[2].Name()) |
| 746 | } |
| 747 | if doc.Fields[3].Name() != "Contact3" { |
| 748 | t.Errorf("expected field named 'Contact3', got '%s'", doc.Fields[3].Name()) |
| 749 | } |
| 750 | |
| 751 | type AnotherThing struct { |
| 752 | Contact0 `json:"Alternate0"` |
| 753 | Contact1 `json:"Alternate1"` |
| 754 | Contact2 `json:"Alternate2"` |
| 755 | Contact3 `json:"Alternate3"` |
nothing calls this directly
no test coverage detected
searching dependent graphs…