(t *testing.T)
| 397 | } |
| 398 | |
| 399 | func Test_decoderBuilder(t *testing.T) { |
| 400 | t.Parallel() |
| 401 | type customInt int |
| 402 | conv := func(s string) reflect.Value { |
| 403 | i, err := strconv.Atoi(s) |
| 404 | if err != nil { |
| 405 | panic(err) |
| 406 | } |
| 407 | return reflect.ValueOf(customInt(i)) |
| 408 | } |
| 409 | parserConfig := ParserConfig{ |
| 410 | SetAliasTag: "custom", |
| 411 | ParserType: []ParserType{{ |
| 412 | CustomType: customInt(0), |
| 413 | Converter: conv, |
| 414 | }}, |
| 415 | IgnoreUnknownKeys: false, |
| 416 | ZeroEmpty: false, |
| 417 | } |
| 418 | decAny := decoderBuilder(bindingForm, parserConfig) |
| 419 | dec, ok := decAny.(*schema.Decoder) |
| 420 | require.True(t, ok) |
| 421 | var out struct { |
| 422 | X customInt `custom:"x"` |
| 423 | } |
| 424 | err := dec.Decode(&out, map[string][]string{"x": {"7"}}) |
| 425 | require.NoError(t, err) |
| 426 | require.Equal(t, customInt(7), out.X) |
| 427 | } |
| 428 | |
| 429 | func Test_parseToMap_Extended(t *testing.T) { |
| 430 | t.Parallel() |
nothing calls this directly
no test coverage detected