Codebase list golang-github-go-playground-validator-v10 / 89a5909
add test to ensure 100% of the lines of code are called, even in the pool joeybloggs 8 years ago
2 changed file(s) with 27 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
2222 *.test
2323 *.prof
2424 *.test
25 *.out
25 *.out
26 cover.html
1212 // - Run "go test" to run tests
1313 // - Run "gocov test | gocov report" to report on test converage by file
1414 // - Run "gocov test | gocov annotate -" to report on all code and functions, those ,marked with "MISS" were never called
15 //
16 // or
17 //
18 // -- may be a good idea to change to output path to somewherelike /tmp
19 // go test -coverprofile cover.out && go tool cover -html=cover.out -o cover.html
1520 //
1621 //
1722 // go test -cpuprofile cpu.out
37643769
37653770 PanicMatches(t, func() { validate.Field(s.Test, "zzxxBadFunction") }, fmt.Sprintf("Undefined validation function on field %s", ""))
37663771 }
3772
3773 func TestPoolObjectMaxSizeValidation(t *testing.T) {
3774 // this will ensure that the pool objects are let go
3775 // when the pool is saturated
3776 validate.SetMaxStructPoolSize(0)
3777
3778 tSuccess := &TestSlice{
3779 Required: []int{1},
3780 Len: []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0},
3781 Min: []int{1, 2},
3782 Max: []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0},
3783 MinMax: []int{1, 2, 3, 4, 5},
3784 OmitEmpty: []int{},
3785 }
3786
3787 for i := 0; i < 2; i++ {
3788 err := validate.Struct(tSuccess)
3789 Equal(t, err, nil)
3790 }
3791 }