(t *testing.T)
| 124 | } |
| 125 | |
| 126 | func Test_SetParserDecoder_CustomConverter(t *testing.T) { |
| 127 | type myInt int |
| 128 | conv := func(s string) reflect.Value { |
| 129 | v, _ := strconv.Atoi(s) //nolint:errcheck // not needed |
| 130 | mi := myInt(v) |
| 131 | return reflect.ValueOf(mi) |
| 132 | } |
| 133 | |
| 134 | SetParserDecoder(ParserConfig{ParserType: []ParserType{{CustomType: myInt(0), Converter: conv}}}) |
| 135 | defer SetParserDecoder(ParserConfig{IgnoreUnknownKeys: true, ZeroEmpty: true}) |
| 136 | |
| 137 | type data struct { |
| 138 | V myInt `query:"v"` |
| 139 | } |
| 140 | d := new(data) |
| 141 | err := parse("query", d, map[string][]string{"v": {"5"}}) |
| 142 | require.NoError(t, err) |
| 143 | require.Equal(t, myInt(5), d.V) |
| 144 | } |
| 145 | |
| 146 | // Test_SetParserDecoder_AliasTagIgnored: ParserConfig.SetAliasTag must not |
| 147 | // override the per-source binding tag (one global tag breaks multi-source binding). |
nothing calls this directly
no test coverage detected