forked from leanovate/gopter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
properties_test.go
47 lines (38 loc) · 937 Bytes
/
properties_test.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
package gopter_test
import (
"os"
"testing"
"github.com/leanovate/gopter"
"github.com/leanovate/gopter/gen"
"github.com/leanovate/gopter/prop"
)
func TestProperties(t *testing.T) {
parameters := gopter.DefaultTestParameters()
properties := gopter.NewProperties(parameters)
properties.Property("always fail", prop.ForAll(
func(v int32) bool {
return false
},
gen.Int32(),
))
fakeT := &testing.T{}
properties.TestingRun(fakeT)
if !fakeT.Failed() {
t.Errorf("fakeT has not failed")
}
}
func TestPropertiesCustomReporter(t *testing.T) {
parameters := gopter.DefaultTestParameters()
properties := gopter.NewProperties(parameters)
properties.Property("always fail", prop.ForAll(
func(v int32) bool {
return false
},
gen.Int32(),
))
fakeT := &testing.T{}
properties.TestingRun(fakeT, gopter.NewFormatedReporter(true, 160, os.Stdout))
if !fakeT.Failed() {
t.Errorf("fakeT has not failed")
}
}