add test to ensure 100% of the lines of code are called, even in the pool
joeybloggs
8 years ago
12 | 12 | // - Run "go test" to run tests |
13 | 13 | // - Run "gocov test | gocov report" to report on test converage by file |
14 | 14 | // - 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 | |
15 | 20 | // |
16 | 21 | // |
17 | 22 | // go test -cpuprofile cpu.out |
3764 | 3769 | |
3765 | 3770 | PanicMatches(t, func() { validate.Field(s.Test, "zzxxBadFunction") }, fmt.Sprintf("Undefined validation function on field %s", "")) |
3766 | 3771 | } |
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 | } |