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

Function TestAsMap

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

Source from the content-addressed store, hash-verified

132}
133
134func TestAsMap(t *testing.T) {
135 var (
136 mapIntString = &Map{
137 KeyType: &AttributeExpr{
138 Type: Int,
139 },
140 ElemType: &AttributeExpr{
141 Type: String,
142 },
143 }
144 mapUserType = &UserTypeExpr{
145 AttributeExpr: &AttributeExpr{
146 Type: mapIntString,
147 },
148 }
149 notMapUserType = &UserTypeExpr{
150 AttributeExpr: &AttributeExpr{
151 Type: Boolean,
152 },
153 }
154 mapResultType = &ResultTypeExpr{
155 UserTypeExpr: mapUserType,
156 }
157 notMapResultType = &ResultTypeExpr{
158 UserTypeExpr: notMapUserType,
159 }
160 )
161 cases := map[string]struct {
162 dt DataType
163 expected *Map
164 }{
165 "map user type": {
166 dt: mapUserType,
167 expected: mapIntString,
168 },
169 "not map user type": {
170 dt: notMapUserType,
171 expected: nil,
172 },
173 "map result type": {
174 dt: mapResultType,
175 expected: mapIntString,
176 },
177 "not map result type": {
178 dt: notMapResultType,
179 expected: nil,
180 },
181 "map": {
182 dt: mapIntString,
183 expected: mapIntString,
184 },
185 "not map": {
186 dt: Boolean,
187 expected: nil,
188 },
189 }
190
191 for k, tc := range cases {

Callers

nothing calls this directly

Calls 2

AsMapFunction · 0.85
EqualFunction · 0.85

Tested by

no test coverage detected