TestMapperMethodsByName tests Mapper methods FieldByName and TraversalsByName
(t *testing.T)
| 629 | |
| 630 | // TestMapperMethodsByName tests Mapper methods FieldByName and TraversalsByName |
| 631 | func TestMapperMethodsByName(t *testing.T) { |
| 632 | type C struct { |
| 633 | C0 string |
| 634 | C1 int |
| 635 | } |
| 636 | type B struct { |
| 637 | B0 *C `db:"B0"` |
| 638 | B1 C `db:"B1"` |
| 639 | B2 string `db:"B2"` |
| 640 | } |
| 641 | type A struct { |
| 642 | A0 *B `db:"A0"` |
| 643 | B `db:"A1"` |
| 644 | A2 int |
| 645 | } |
| 646 | |
| 647 | val := &A{ |
| 648 | A0: &B{ |
| 649 | B0: &C{C0: "0", C1: 1}, |
| 650 | B1: C{C0: "2", C1: 3}, |
| 651 | B2: "4", |
| 652 | }, |
| 653 | B: B{ |
| 654 | B0: nil, |
| 655 | B1: C{C0: "5", C1: 6}, |
| 656 | B2: "7", |
| 657 | }, |
| 658 | A2: 8, |
| 659 | } |
| 660 | |
| 661 | testCases := []struct { |
| 662 | Name string |
| 663 | ExpectInvalid bool |
| 664 | ExpectedValue interface{} |
| 665 | ExpectedIndexes []int |
| 666 | }{ |
| 667 | { |
| 668 | Name: "A0.B0.C0", |
| 669 | ExpectedValue: "0", |
| 670 | ExpectedIndexes: []int{0, 0, 0}, |
| 671 | }, |
| 672 | { |
| 673 | Name: "A0.B0.C1", |
| 674 | ExpectedValue: 1, |
| 675 | ExpectedIndexes: []int{0, 0, 1}, |
| 676 | }, |
| 677 | { |
| 678 | Name: "A0.B1.C0", |
| 679 | ExpectedValue: "2", |
| 680 | ExpectedIndexes: []int{0, 1, 0}, |
| 681 | }, |
| 682 | { |
| 683 | Name: "A0.B1.C1", |
| 684 | ExpectedValue: 3, |
| 685 | ExpectedIndexes: []int{0, 1, 1}, |
| 686 | }, |
| 687 | { |
| 688 | Name: "A0.B2", |
nothing calls this directly
no test coverage detected