(t *testing.T)
| 704 | } |
| 705 | |
| 706 | func TestArrayIsCompatible(t *testing.T) { |
| 707 | var ( |
| 708 | b = true |
| 709 | i = 1 |
| 710 | ia = [2]int{1, 2} |
| 711 | is = []int{3, 4} |
| 712 | ) |
| 713 | cases := map[string]struct { |
| 714 | typ DataType |
| 715 | values []any |
| 716 | expected bool |
| 717 | }{ |
| 718 | "compatible": { |
| 719 | typ: Int, |
| 720 | values: []any{ia, is}, |
| 721 | expected: true, |
| 722 | }, |
| 723 | "not array and slice": { |
| 724 | typ: String, |
| 725 | values: []any{b, i}, |
| 726 | expected: false, |
| 727 | }, |
| 728 | "array but not compatible": { |
| 729 | typ: String, |
| 730 | values: []any{ia}, |
| 731 | expected: false, |
| 732 | }, |
| 733 | "slice but not compatible": { |
| 734 | typ: String, |
| 735 | values: []any{is}, |
| 736 | expected: false, |
| 737 | }, |
| 738 | } |
| 739 | |
| 740 | for k, tc := range cases { |
| 741 | array := Array{ |
| 742 | ElemType: &AttributeExpr{ |
| 743 | Type: tc.typ, |
| 744 | }, |
| 745 | } |
| 746 | for _, value := range tc.values { |
| 747 | if actual := array.IsCompatible(value); tc.expected != actual { |
| 748 | t.Errorf("%s: got %#v, expected %#v", k, actual, tc.expected) |
| 749 | } |
| 750 | } |
| 751 | } |
| 752 | } |
| 753 | |
| 754 | func TestObjectRename(t *testing.T) { |
| 755 | cases := map[string]struct { |
nothing calls this directly
no test coverage detected