-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathisnilassert_test.go
More file actions
61 lines (57 loc) · 1.07 KB
/
isnilassert_test.go
File metadata and controls
61 lines (57 loc) · 1.07 KB
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
55
56
57
58
59
60
61
package texp_test
import (
"strings"
"testing"
"github.com/gekorob/texp"
"github.com/gekorob/texp/conf"
"github.com/gekorob/texp/mock"
)
var nilTests = []struct {
N string
T func(texp.ExpBuilder)
A func(*mock.TMock) bool
}{
{
N: "NilIsNil",
T: func(expect texp.ExpBuilder) {
expect(nil).ToBeNil()
},
A: func(tM *mock.TMock) bool {
return !testFailInvoked(tM)
},
},
{
N: "EmptyStructPointerNil",
T: func(expect texp.ExpBuilder) {
type FakeObj struct {
}
expect((*struct{})(nil)).ToBeNil()
},
A: func(tM *mock.TMock) bool {
return !testFailInvoked(tM)
},
},
{
N: "NewObjNotNil",
T: func(expect texp.ExpBuilder) {
type FakeObj struct {
}
expect(new(FakeObj)).ToBeNil()
},
A: func(tM *mock.TMock) bool {
return testFailInvoked(tM)
},
},
}
func TestIsNil(t *testing.T) {
for _, tt := range nilTests {
t.Run(tt.N, func(t *testing.T) {
tMock := mock.NewTMock()
expect := texp.Expect(tMock, conf.OutputTo(new(strings.Builder)))
tt.T(expect)
if !tt.A(tMock) {
t.Errorf("Wrong calls to Fail")
}
})
}
}