@@ -14,6 +14,11 @@ import (
1414// - Run "gocov test | gocov report" to report on test converage by file
1515// - Run "gocov test | gocov annotate -" to report on all code and functions, those ,marked with "MISS" were never called
1616//
17+ // or
18+ //
19+ // -- may be a good idea to change to output path to somewherelike /tmp
20+ // go test -coverprofile cover.out && go tool cover -html=cover.out -o cover.html
21+ //
1722//
1823// go test -cpuprofile cpu.out
1924// ./validator.test -test.bench=. -test.cpuprofile=cpu.prof
@@ -3765,3 +3770,23 @@ func TestInvalidValidatorFunction(t *testing.T) {
37653770
37663771 PanicMatches (t , func () { validate .Field (s .Test , "zzxxBadFunction" ) }, fmt .Sprintf ("Undefined validation function on field %s" , "" ))
37673772}
3773+
3774+ func TestPoolObjectMaxSizeValidation (t * testing.T ) {
3775+ // this will ensure that the pool objects are let go
3776+ // when the pool is saturated
3777+ validate .SetMaxStructPoolSize (0 )
3778+
3779+ tSuccess := & TestSlice {
3780+ Required : []int {1 },
3781+ Len : []int {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 },
3782+ Min : []int {1 , 2 },
3783+ Max : []int {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 },
3784+ MinMax : []int {1 , 2 , 3 , 4 , 5 },
3785+ OmitEmpty : []int {},
3786+ }
3787+
3788+ for i := 0 ; i < 2 ; i ++ {
3789+ err := validate .Struct (tSuccess )
3790+ Equal (t , err , nil )
3791+ }
3792+ }
0 commit comments