github.com/leanovate/gopter@v0.2.9/doc.go (about)

     1  /*
     2  Package gopter contain the main interfaces of the GOlang Property TestER.
     3  
     4  A simple property test might look like this:
     5  
     6      func TestSqrt(t *testing.T) {
     7      	properties := gopter.NewProperties(nil)
     8  
     9      	properties.Property("greater one of all greater one", prop.ForAll(
    10      		func(v float64) bool {
    11      			return math.Sqrt(v) >= 1
    12      		},
    13      		gen.Float64Range(1, math.MaxFloat64),
    14      	))
    15  
    16      	properties.Property("squared is equal to value", prop.ForAll(
    17      		func(v float64) bool {
    18      			r := math.Sqrt(v)
    19      			return math.Abs(r*r-v) < 1e-10*v
    20      		},
    21      		gen.Float64Range(0, math.MaxFloat64),
    22      	))
    23  
    24      	properties.TestingRun(t)
    25      }
    26  
    27  Generally a property is just a function that takes GenParameters and produces
    28  a PropResult:
    29  
    30      type Prop func(*GenParameters) *PropResult
    31  
    32  but usually you will use prop.ForAll, prop.ForAllNoShrink or arbitrary.ForAll.
    33  There is also the commands package, which can be helpful for stateful testing.
    34  */
    35  package gopter