| 327 | } |
| 328 | |
| 329 | func TestIsMap(t *testing.T) { |
| 330 | var ( |
| 331 | mapIntString = &Map{ |
| 332 | KeyType: &AttributeExpr{ |
| 333 | Type: Int, |
| 334 | }, |
| 335 | ElemType: &AttributeExpr{ |
| 336 | Type: String, |
| 337 | }, |
| 338 | } |
| 339 | mapUserType = &UserTypeExpr{ |
| 340 | AttributeExpr: &AttributeExpr{ |
| 341 | Type: mapIntString, |
| 342 | }, |
| 343 | } |
| 344 | notMapUserType = &UserTypeExpr{ |
| 345 | AttributeExpr: &AttributeExpr{ |
| 346 | Type: Boolean, |
| 347 | }, |
| 348 | } |
| 349 | mapResultType = &ResultTypeExpr{ |
| 350 | UserTypeExpr: mapUserType, |
| 351 | } |
| 352 | notMapResultType = &ResultTypeExpr{ |
| 353 | UserTypeExpr: notMapUserType, |
| 354 | } |
| 355 | ) |
| 356 | cases := map[string]struct { |
| 357 | dt DataType |
| 358 | expected bool |
| 359 | }{ |
| 360 | "map user type": { |
| 361 | dt: mapUserType, |
| 362 | expected: true, |
| 363 | }, |
| 364 | "not map user type": { |
| 365 | dt: notMapUserType, |
| 366 | expected: false, |
| 367 | }, |
| 368 | "map result type": { |
| 369 | dt: mapResultType, |
| 370 | expected: true, |
| 371 | }, |
| 372 | "not map result type": { |
| 373 | dt: notMapResultType, |
| 374 | expected: false, |
| 375 | }, |
| 376 | "map": { |
| 377 | dt: mapIntString, |
| 378 | expected: true, |
| 379 | }, |
| 380 | "not map": { |
| 381 | dt: Boolean, |
| 382 | expected: false, |
| 383 | }, |
| 384 | } |
| 385 | |
| 386 | for k, tc := range cases { |