MCPcopy Index your code
hub / github.com/labstack/echo / TestBindSetWithProperType

Function TestBindSetWithProperType

bind_test.go:642–668  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

640}
641
642func TestBindSetWithProperType(t *testing.T) {
643 ts := new(bindTestStruct)
644 typ := reflect.TypeFor[bindTestStruct]()
645 val := reflect.ValueOf(ts).Elem()
646 for i := 0; i < typ.NumField(); i++ {
647 typeField := typ.Field(i)
648 structField := val.Field(i)
649 if !structField.CanSet() {
650 continue
651 }
652 if len(values[typeField.Name]) == 0 {
653 continue
654 }
655 val := values[typeField.Name][0]
656 err := setWithProperType(typeField.Type.Kind(), val, structField)
657 assert.NoError(t, err)
658 }
659 assertBindTestStruct(t, ts)
660
661 type foo struct {
662 Bar bytes.Buffer
663 }
664 v := &foo{}
665 typ = reflect.TypeFor[foo]()
666 val = reflect.ValueOf(v).Elem()
667 assert.Error(t, setWithProperType(typ.Field(0).Type.Kind(), "5", val.Field(0)))
668}
669
670func BenchmarkBindbindDataWithTags(b *testing.B) {
671 b.ReportAllocs()

Callers

nothing calls this directly

Calls 3

setWithProperTypeFunction · 0.85
assertBindTestStructFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…