add test to ensure 100% of the lines of code are called, even in the pool

pull/95/head
joeybloggs 10 years ago
parent 82abe38795
commit 89a5909004
  1. 1
      .gitignore
  2. 25
      validator_test.go

1
.gitignore vendored

@ -24,3 +24,4 @@ _testmain.go
*.prof *.prof
*.test *.test
*.out *.out
cover.html

@ -14,6 +14,11 @@ import (
// - Run "gocov test | gocov report" to report on test converage by file // - Run "gocov test | gocov report" to report on test converage by file
// - Run "gocov test | gocov annotate -" to report on all code and functions, those ,marked with "MISS" were never called // - Run "gocov test | gocov annotate -" to report on all code and functions, those ,marked with "MISS" were never called
// //
// or
//
// -- may be a good idea to change to output path to somewherelike /tmp
// go test -coverprofile cover.out && go tool cover -html=cover.out -o cover.html
//
// //
// go test -cpuprofile cpu.out // go test -cpuprofile cpu.out
// ./validator.test -test.bench=. -test.cpuprofile=cpu.prof // ./validator.test -test.bench=. -test.cpuprofile=cpu.prof
@ -3765,3 +3770,23 @@ func TestInvalidValidatorFunction(t *testing.T) {
PanicMatches(t, func() { validate.Field(s.Test, "zzxxBadFunction") }, fmt.Sprintf("Undefined validation function on field %s", "")) PanicMatches(t, func() { validate.Field(s.Test, "zzxxBadFunction") }, fmt.Sprintf("Undefined validation function on field %s", ""))
} }
func TestPoolObjectMaxSizeValidation(t *testing.T) {
// this will ensure that the pool objects are let go
// when the pool is saturated
validate.SetMaxStructPoolSize(0)
tSuccess := &TestSlice{
Required: []int{1},
Len: []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0},
Min: []int{1, 2},
Max: []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0},
MinMax: []int{1, 2, 3, 4, 5},
OmitEmpty: []int{},
}
for i := 0; i < 2; i++ {
err := validate.Struct(tSuccess)
Equal(t, err, nil)
}
}

Loading…
Cancel
Save