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

     1  package prop_test
     2  
     3  import (
     4  	"github.com/leanovate/gopter"
     5  	"github.com/leanovate/gopter/gen"
     6  	"github.com/leanovate/gopter/prop"
     7  )
     8  
     9  func Example_shrink() {
    10  	parameters := gopter.DefaultTestParametersWithSeed(1234) // Example should generate reproducible results, otherwise DefaultTestParameters() will suffice
    11  
    12  	properties := gopter.NewProperties(parameters)
    13  
    14  	properties.Property("fail above 100", prop.ForAll(
    15  		func(arg int64) bool {
    16  			return arg <= 100
    17  		},
    18  		gen.Int64(),
    19  	))
    20  
    21  	properties.Property("fail above 100 no shrink", prop.ForAllNoShrink(
    22  		func(arg int64) bool {
    23  			return arg <= 100
    24  		},
    25  		gen.Int64(),
    26  	))
    27  
    28  	// When using testing.T you might just use: properties.TestingRun(t)
    29  	properties.Run(gopter.ConsoleReporter(false))
    30  	// Output:
    31  	// ! fail above 100: Falsified after 0 passed tests.
    32  	// ARG_0: 101
    33  	// ARG_0_ORIGINAL (56 shrinks): 2041104533947223744
    34  	// ! fail above 100 no shrink: Falsified after 0 passed tests.
    35  	// ARG_0: 6006156956070140861
    36  }