(t *testing.T)
| 828 | } |
| 829 | |
| 830 | func TestMapIsCompatible(t *testing.T) { |
| 831 | var ( |
| 832 | b = true |
| 833 | i = 1 |
| 834 | ism = map[int]string{ |
| 835 | 1: "foo", |
| 836 | } |
| 837 | ssm = map[string]string{ |
| 838 | "bar": "bar", |
| 839 | } |
| 840 | iim = map[int]int{ |
| 841 | 2: 2, |
| 842 | } |
| 843 | ) |
| 844 | cases := map[string]struct { |
| 845 | values []any |
| 846 | expected bool |
| 847 | }{ |
| 848 | "compatible": { |
| 849 | values: []any{ism}, |
| 850 | expected: true, |
| 851 | }, |
| 852 | "not comatible": { |
| 853 | values: []any{b, i}, |
| 854 | expected: false, |
| 855 | }, |
| 856 | "map but not comatible": { |
| 857 | values: []any{ssm, iim}, |
| 858 | expected: false, |
| 859 | }, |
| 860 | } |
| 861 | |
| 862 | m := Map{ |
| 863 | KeyType: &AttributeExpr{ |
| 864 | Type: Int, |
| 865 | }, |
| 866 | ElemType: &AttributeExpr{ |
| 867 | Type: String, |
| 868 | }, |
| 869 | } |
| 870 | for k, tc := range cases { |
| 871 | for _, value := range tc.values { |
| 872 | if actual := m.IsCompatible(value); tc.expected != actual { |
| 873 | t.Errorf("%s: got %#v, expected %#v", k, actual, tc.expected) |
| 874 | } |
| 875 | } |
| 876 | } |
| 877 | } |
| 878 | |
| 879 | func TestUnionGetTypeKey(t *testing.T) { |
| 880 | cases := map[string]struct { |
nothing calls this directly
no test coverage detected