File tree Expand file tree Collapse file tree 1 file changed +37
-8
lines changed Expand file tree Collapse file tree 1 file changed +37
-8
lines changed Original file line number Diff line number Diff line change @@ -2326,17 +2326,46 @@ func BenchmarkValidateField(b *testing.B) {
23262326}
23272327
23282328func BenchmarkValidateStruct (b * testing.B ) {
2329- type Test struct {
2330- StringVal string `bson:"required,lt=10"`
2331- Int64Val int64 `bson:"gt=0,lt=10"`
2332- }
23332329
2334- t := & Test {
2335- StringVal : "test" ,
2336- Int64Val : 5 ,
2330+ // type Inner struct {
2331+
2332+ // }
2333+
2334+ // type Test struct {
2335+ // StringVal string `bson:"required,lt=10"`
2336+ // Int64Val int64 `bson:"gt=0,lt=10"`
2337+ // }
2338+
2339+ tFail := & TestString {
2340+ Required : "" ,
2341+ Len : "" ,
2342+ Min : "" ,
2343+ Max : "12345678901" ,
2344+ MinMax : "" ,
2345+ Lt : "0123456789" ,
2346+ Lte : "01234567890" ,
2347+ Gt : "1" ,
2348+ Gte : "1" ,
2349+ OmitEmpty : "12345678901" ,
2350+ Sub : & SubTest {
2351+ Test : "" ,
2352+ },
2353+ Anonymous : struct {
2354+ A string `validate:"required"`
2355+ }{
2356+ A : "" ,
2357+ },
2358+ Iface : & Impl {
2359+ F : "12" ,
2360+ },
23372361 }
23382362
2363+ // t := &Test{
2364+ // StringVal: "test",
2365+ // Int64Val: 5,
2366+ // }
2367+
23392368 for n := 0 ; n < b .N ; n ++ {
2340- validate .Struct (t )
2369+ validate .Struct (tFail )
23412370 }
23422371}
You can’t perform that action at this time.
0 commit comments