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

Function TestIsArray

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

Source from the content-addressed store, hash-verified

264}
265
266func TestIsArray(t *testing.T) {
267 var (
268 array = &Array{
269 ElemType: &AttributeExpr{
270 Type: String,
271 },
272 }
273 arrayUserType = &UserTypeExpr{
274 AttributeExpr: &AttributeExpr{
275 Type: array,
276 },
277 }
278 notArrayUserType = &UserTypeExpr{
279 AttributeExpr: &AttributeExpr{
280 Type: Boolean,
281 },
282 }
283 arrayResultType = &ResultTypeExpr{
284 UserTypeExpr: arrayUserType,
285 }
286 notArrayResultType = &ResultTypeExpr{
287 UserTypeExpr: notArrayUserType,
288 }
289 )
290 cases := map[string]struct {
291 dt DataType
292 expected bool
293 }{
294 "array user type": {
295 dt: arrayUserType,
296 expected: true,
297 },
298 "not array user type": {
299 dt: notArrayUserType,
300 expected: false,
301 },
302 "array result type": {
303 dt: arrayResultType,
304 expected: true,
305 },
306 "not array result type": {
307 dt: notArrayResultType,
308 expected: false,
309 },
310 "array": {
311 dt: array,
312 expected: true,
313 },
314 "not array": {
315 dt: Boolean,
316 expected: false,
317 },
318 }
319
320 for k, tc := range cases {
321 if actual := IsArray(tc.dt); actual != tc.expected {
322 if actual != tc.expected {
323 t.Errorf("%s: got %#v, expected %#v", k, actual, tc.expected)

Callers

nothing calls this directly

Calls 1

IsArrayFunction · 0.85

Tested by

no test coverage detected