-
Notifications
You must be signed in to change notification settings - Fork 0
/
option_test.go
54 lines (44 loc) · 1.25 KB
/
option_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
48
49
50
51
52
53
54
package assert_test
import (
"testing"
. "github.com/pierrre/assert"
"github.com/pierrre/assert/asserttest"
)
func TestOptionAllocs(t *testing.T) {
AllocsPerRun(t, 100, func() {
Equal(t, 123, 123, Message("test"))
}, 1)
}
func TestLazy(t *testing.T) {
report := asserttest.NewReportAuto(t)
Fail(t, "test", "message", Report(report), Lazy(func() Option {
return Message("custom")
}))
}
func TestLazyAllocs(t *testing.T) {
AllocsPerRun(t, 100, func() {
Equal(t, 123, 123, Lazy(func() Option {
return Message("test")
}))
}, 0)
}
func TestOptions(t *testing.T) {
report := asserttest.NewReportAuto(t)
Fail(t, "test", "message", Options(Report(report), Message("custom")))
}
func TestMessage(t *testing.T) {
report := asserttest.NewReportAuto(t)
Fail(t, "test", "message", Report(report), Message("custom"))
}
func TestMessagef(t *testing.T) {
report := asserttest.NewReportAuto(t)
Fail(t, "test", "message", Report(report), Messagef("custom %d", 1))
}
func TestMessageWrap(t *testing.T) {
report := asserttest.NewReportAuto(t)
Fail(t, "test", "message", Report(report), MessageWrap("custom"))
}
func TestMessageWrapf(t *testing.T) {
report := asserttest.NewReportAuto(t)
Fail(t, "test", "message", Report(report), MessageWrapf("custom %d", 1))
}