MCPcopy
hub / github.com/gin-gonic/gin / TestMappingDefault

Function TestMappingDefault

binding/form_mapping_test.go:71–85  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

69}
70
71func TestMappingDefault(t *testing.T) {
72 var s struct {
73 Str string `form:",default=defaultVal"`
74 Int int `form:",default=9"`
75 Slice []int `form:",default=9"`
76 Array [1]int `form:",default=9"`
77 }
78 err := mappingByPtr(&s, formSource{}, "form")
79 require.NoError(t, err)
80
81 assert.Equal(t, "defaultVal", s.Str)
82 assert.Equal(t, 9, s.Int)
83 assert.Equal(t, []int{9}, s.Slice)
84 assert.Equal(t, [1]int{9}, s.Array)
85}
86
87func TestMappingSkipField(t *testing.T) {
88 var s struct {

Callers

nothing calls this directly

Calls 1

mappingByPtrFunction · 0.85

Tested by

no test coverage detected