Home / File/ form_mapping_test.go — gin Source File

form_mapping_test.go — gin Source File

Architecture documentation for form_mapping_test.go, a go file in the gin codebase. 1 imports, 0 dependents.

File go RequestBinding FormBinding 1 imports 64 functions 9 classes

Entity Profile

Dependency Diagram

graph LR
  36de44f8_6a8c_78ab_4c20_59952e276c82["form_mapping_test.go"]
  ba6df5a0_c664_7fb2_95fb_0bdbdc441db8["encoding"]
  36de44f8_6a8c_78ab_4c20_59952e276c82 --> ba6df5a0_c664_7fb2_95fb_0bdbdc441db8
  style 36de44f8_6a8c_78ab_4c20_59952e276c82 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// Copyright 2019 Gin Core Team. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.

package binding

import (
	"encoding"
	"encoding/hex"
	"errors"
	"mime/multipart"
	"reflect"
	"strconv"
	"strings"
	"testing"
	"time"

	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
)

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))

// ... (1087 more lines)

Subdomains

Functions

Dependencies

  • encoding

Frequently Asked Questions

What does form_mapping_test.go do?
form_mapping_test.go is a source file in the gin codebase, written in go. It belongs to the RequestBinding domain, FormBinding subdomain.
What functions are defined in form_mapping_test.go?
form_mapping_test.go defines 64 function(s): TestMapFormWithTag, TestMappingArray, TestMappingBaseTypes, TestMappingCollectionFormat, TestMappingCollectionFormatInvalid, TestMappingCustomArrayForm, TestMappingCustomArrayOfArrayForm, TestMappingCustomArrayOfArrayUnmarshalTextDefault, TestMappingCustomArrayOfArrayUnmarshalTextForm, TestMappingCustomArrayOfArrayUnmarshalTextUri, and 54 more.
What does form_mapping_test.go depend on?
form_mapping_test.go imports 1 module(s): encoding.
Where is form_mapping_test.go in the architecture?
form_mapping_test.go is located at binding/form_mapping_test.go (domain: RequestBinding, subdomain: FormBinding, directory: binding).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free