MCPcopy Create free account
hub / github.com/goadesign/goa / TestArrayIsCompatible

Function TestArrayIsCompatible

expr/types_test.go:706–752  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

704}
705
706func 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
754func TestObjectRename(t *testing.T) {
755 cases := map[string]struct {

Callers

nothing calls this directly

Calls 1

IsCompatibleMethod · 0.95

Tested by

no test coverage detected