| 871 | } |
| 872 | |
| 873 | func TestIsFoldedMerge(t *testing.T) { |
| 874 | testProfile1Folded := testProfile1.Copy() |
| 875 | testProfile1Folded.Location[0].IsFolded = true |
| 876 | testProfile1Folded.Location[1].IsFolded = true |
| 877 | |
| 878 | for _, tc := range []struct { |
| 879 | name string |
| 880 | profs []*Profile |
| 881 | wantLocationLen int |
| 882 | }{ |
| 883 | { |
| 884 | name: "folded and non-folded locations not merged", |
| 885 | profs: []*Profile{testProfile1.Copy(), testProfile1Folded.Copy()}, |
| 886 | wantLocationLen: 7, |
| 887 | }, |
| 888 | { |
| 889 | name: "identical folded locations are merged", |
| 890 | profs: []*Profile{testProfile1Folded.Copy(), testProfile1Folded.Copy()}, |
| 891 | wantLocationLen: 5, |
| 892 | }, |
| 893 | } { |
| 894 | t.Run(tc.name, func(t *testing.T) { |
| 895 | prof, err := Merge(tc.profs) |
| 896 | if err != nil { |
| 897 | t.Fatalf("merge error: %v", err) |
| 898 | } |
| 899 | if got, want := len(prof.Location), tc.wantLocationLen; got != want { |
| 900 | t.Fatalf("got %d locations, want %d locations", got, want) |
| 901 | } |
| 902 | }) |
| 903 | } |
| 904 | } |
| 905 | |
| 906 | func TestNumLabelMerge(t *testing.T) { |
| 907 | for _, tc := range []struct { |