github.com/leanovate/gopter@v0.2.9/arbitrary/example_parseint_test.go (about) 1 package arbitrary_test 2 3 import ( 4 "fmt" 5 "strconv" 6 7 "github.com/leanovate/gopter" 8 "github.com/leanovate/gopter/arbitrary" 9 ) 10 11 func Example_parseint() { 12 parameters := gopter.DefaultTestParametersWithSeed(1234) // Example should generate reproducible results, otherwise DefaultTestParameters() will suffice 13 14 arbitraries := arbitrary.DefaultArbitraries() 15 properties := gopter.NewProperties(parameters) 16 17 properties.Property("printed integers can be parsed", arbitraries.ForAll( 18 func(a int64) bool { 19 str := fmt.Sprintf("%d", a) 20 parsed, err := strconv.ParseInt(str, 10, 64) 21 return err == nil && parsed == a 22 })) 23 24 // When using testing.T you might just use: properties.TestingRun(t) 25 properties.Run(gopter.ConsoleReporter(false)) 26 // Output: 27 // + printed integers can be parsed: OK, passed 100 tests. 28 }