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

Function TestAsArray

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

Source from the content-addressed store, hash-verified

69}
70
71func TestAsArray(t *testing.T) {
72 var (
73 array = &Array{
74 ElemType: &AttributeExpr{
75 Type: String,
76 },
77 }
78 arrayUserType = &UserTypeExpr{
79 AttributeExpr: &AttributeExpr{
80 Type: array,
81 },
82 }
83 notArrayUserType = &UserTypeExpr{
84 AttributeExpr: &AttributeExpr{
85 Type: Boolean,
86 },
87 }
88 arrayResultType = &ResultTypeExpr{
89 UserTypeExpr: arrayUserType,
90 }
91 notArrayResultType = &ResultTypeExpr{
92 UserTypeExpr: notArrayUserType,
93 }
94 )
95 cases := map[string]struct {
96 dt DataType
97 expected *Array
98 }{
99 "array user type": {
100 dt: arrayUserType,
101 expected: array,
102 },
103 "not array user type": {
104 dt: notArrayUserType,
105 expected: nil,
106 },
107 "array result type": {
108 dt: arrayResultType,
109 expected: array,
110 },
111 "not array result type": {
112 dt: notArrayResultType,
113 expected: nil,
114 },
115 "array": {
116 dt: array,
117 expected: array,
118 },
119 "not array": {
120 dt: Boolean,
121 expected: nil,
122 },
123 }
124
125 for k, tc := range cases {
126 if actual := AsArray(tc.dt); actual != tc.expected {
127 if Equal(actual, tc.expected) != true {
128 t.Errorf("%s: got %#v, expected %#v", k, actual, tc.expected)

Callers

nothing calls this directly

Calls 2

AsArrayFunction · 0.85
EqualFunction · 0.85

Tested by

no test coverage detected