TestMappingBaseTypes() — gin Function Reference
Architecture documentation for the TestMappingBaseTypes() function in form_mapping_test.go from the gin codebase.
Entity Profile
Dependency Diagram
graph TD 9fec41d0_a985_9472_14e6_e63f8af0b2b5["TestMappingBaseTypes()"] 36de44f8_6a8c_78ab_4c20_59952e276c82["form_mapping_test.go"] 9fec41d0_a985_9472_14e6_e63f8af0b2b5 -->|defined in| 36de44f8_6a8c_78ab_4c20_59952e276c82 style 9fec41d0_a985_9472_14e6_e63f8af0b2b5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
binding/form_mapping_test.go lines 22–69
func TestMappingBaseTypes(t *testing.T) {
intPtr := func(i int) *int {
return &i
}
for _, tt := range []struct {
name string
value any
form string
expect any
}{
{"base type", struct{ F int }{}, "9", int(9)},
{"base type", struct{ F int8 }{}, "9", int8(9)},
{"base type", struct{ F int16 }{}, "9", int16(9)},
{"base type", struct{ F int32 }{}, "9", int32(9)},
{"base type", struct{ F int64 }{}, "9", int64(9)},
{"base type", struct{ F uint }{}, "9", uint(9)},
{"base type", struct{ F uint8 }{}, "9", uint8(9)},
{"base type", struct{ F uint16 }{}, "9", uint16(9)},
{"base type", struct{ F uint32 }{}, "9", uint32(9)},
{"base type", struct{ F uint64 }{}, "9", uint64(9)},
{"base type", struct{ F bool }{}, "True", true},
{"base type", struct{ F float32 }{}, "9.1", float32(9.1)},
{"base type", struct{ F float64 }{}, "9.1", float64(9.1)},
{"base type", struct{ F string }{}, "test", string("test")},
{"base type", struct{ F *int }{}, "9", intPtr(9)},
// zero values
{"zero value", struct{ F int }{}, "", int(0)},
{"zero value", struct{ F uint }{}, "", uint(0)},
{"zero value", struct{ F bool }{}, "", false},
{"zero value", struct{ F float32 }{}, "", float32(0)},
{"file value", struct{ F *multipart.FileHeader }{}, "", &multipart.FileHeader{}},
} {
tp := reflect.TypeOf(tt.value)
testName := tt.name + ":" + tp.Field(0).Type.String()
val := reflect.New(reflect.TypeOf(tt.value))
val.Elem().Set(reflect.ValueOf(tt.value))
field := val.Elem().Type().Field(0)
_, err := mapping(val, emptyField, formSource{field.Name: {tt.form}}, "form")
require.NoError(t, err, testName)
actual := val.Elem().Field(0).Interface()
assert.Equal(t, tt.expect, actual, testName)
}
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does TestMappingBaseTypes() do?
TestMappingBaseTypes() is a function in the gin codebase, defined in binding/form_mapping_test.go.
Where is TestMappingBaseTypes() defined?
TestMappingBaseTypes() is defined in binding/form_mapping_test.go at line 22.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free