form_mapping_benchmark_test.go — gin Source File
Architecture documentation for form_mapping_benchmark_test.go, a go file in the gin codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 652e7bf5_3c89_5be4_42af_9fdbc680bb55["form_mapping_benchmark_test.go"] 0ff88466_66bc_01d5_630e_e073ff70cccb["testing"] 652e7bf5_3c89_5be4_42af_9fdbc680bb55 --> 0ff88466_66bc_01d5_630e_e073ff70cccb style 652e7bf5_3c89_5be4_42af_9fdbc680bb55 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 (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
var form = map[string][]string{
"name": {"mike"},
"friends": {"anna", "nicole"},
"id_number": {"12345678"},
"id_date": {"2018-01-20"},
}
type structFull struct {
Name string `form:"name"`
Age int `form:"age,default=25"`
Friends []string `form:"friends"`
ID *struct {
Number string `form:"id_number"`
DateOfIssue time.Time `form:"id_date" time_format:"2006-01-02" time_utc:"true"`
}
Nationality *string `form:"nationality"`
}
func BenchmarkMapFormFull(b *testing.B) {
var s structFull
for b.Loop() {
err := mapForm(&s, form)
if err != nil {
b.Fatalf("Error on a form mapping")
}
}
b.StopTimer()
t := b
assert.Equal(t, "mike", s.Name)
assert.Equal(t, 25, s.Age)
assert.Equal(t, []string{"anna", "nicole"}, s.Friends)
assert.Equal(t, "12345678", s.ID.Number)
assert.Equal(t, time.Date(2018, 1, 20, 0, 0, 0, 0, time.UTC), s.ID.DateOfIssue)
assert.Nil(t, s.Nationality)
}
type structName struct {
Name string `form:"name"`
}
func BenchmarkMapFormName(b *testing.B) {
var s structName
for b.Loop() {
err := mapForm(&s, form)
if err != nil {
b.Fatalf("Error on a form mapping")
}
}
b.StopTimer()
t := b
assert.Equal(t, "mike", s.Name)
}
Domain
Subdomains
Classes
Dependencies
- testing
Source
Frequently Asked Questions
What does form_mapping_benchmark_test.go do?
form_mapping_benchmark_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_benchmark_test.go?
form_mapping_benchmark_test.go defines 2 function(s): BenchmarkMapFormFull, BenchmarkMapFormName.
What does form_mapping_benchmark_test.go depend on?
form_mapping_benchmark_test.go imports 1 module(s): testing.
Where is form_mapping_benchmark_test.go in the architecture?
form_mapping_benchmark_test.go is located at binding/form_mapping_benchmark_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