-
Notifications
You must be signed in to change notification settings - Fork 40
/
test_parameters.go
48 lines (42 loc) · 1.22 KB
/
test_parameters.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package gopter
import (
"math/rand"
"time"
)
// TestParameters to run property tests
type TestParameters struct {
MinSuccessfulTests int
// MinSize is an (inclusive) lower limit on the size of the parameters
MinSize int
// MaxSize is an (exclusive) upper limit on the size of the parameters
MaxSize int
MaxShrinkCount int
seed int64
Rng *rand.Rand
Workers int
MaxDiscardRatio float64
}
func (t *TestParameters) Seed() int64 {
return t.seed
}
func (t *TestParameters) SetSeed(seed int64) {
t.seed = seed
t.Rng.Seed(seed)
}
// DefaultTestParameterWithSeeds creates reasonable default Parameters for most cases based on a fixed RNG-seed
func DefaultTestParametersWithSeed(seed int64) *TestParameters {
return &TestParameters{
MinSuccessfulTests: 100,
MinSize: 0,
MaxSize: 100,
MaxShrinkCount: 1000,
seed: seed,
Rng: rand.New(NewLockedSource(seed)),
Workers: 1,
MaxDiscardRatio: 5,
}
}
// DefaultTestParameterWithSeeds creates reasonable default Parameters for most cases with an undefined RNG-seed
func DefaultTestParameters() *TestParameters {
return DefaultTestParametersWithSeed(time.Now().UnixNano())
}