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

Function TestObjectIsCompatible

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

Source from the content-addressed store, hash-verified

793}
794
795func TestObjectIsCompatible(t *testing.T) {
796 var (
797 b = true
798 i = 1
799 s = struct {
800 Foo string
801 }{
802 Foo: "foo",
803 }
804 m = map[int]string{}
805 )
806 cases := map[string]struct {
807 values []any
808 expected bool
809 }{
810 "compatible": {
811 values: []any{s, m},
812 expected: true,
813 },
814 "not comatible": {
815 values: []any{b, i},
816 expected: false,
817 },
818 }
819
820 object := Object{}
821 for k, tc := range cases {
822 for _, value := range tc.values {
823 if actual := object.IsCompatible(value); tc.expected != actual {
824 t.Errorf("%s: got %#v, expected %#v", k, actual, tc.expected)
825 }
826 }
827 }
828}
829
830func TestMapIsCompatible(t *testing.T) {
831 var (

Callers

nothing calls this directly

Calls 1

IsCompatibleMethod · 0.95

Tested by

no test coverage detected