-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcall_params_test.go
More file actions
44 lines (35 loc) · 818 Bytes
/
Copy pathcall_params_test.go
File metadata and controls
44 lines (35 loc) · 818 Bytes
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
package funcmock
import (
"testing"
. "github.com/onsi/gomega"
)
var swap = func(i, j int) (int, int) {
return j, i
}
var swapMock = Mock(&swap)
func init() {
swap(3, -5)
swap(-7, 11)
swap(13, -17)
}
func TestCallCounter3(t *testing.T) {
RegisterTestingT(t)
Expect(swapMock.CallCount()).To(Equal(3))
}
func TestCalledTrue(t *testing.T) {
RegisterTestingT(t)
Expect(swapMock.Called()).To(BeTrue())
}
func TestCall0thParams(t *testing.T) {
RegisterTestingT(t)
call0nth := swapMock.NthCall(0)
Expect(call0nth).NotTo(BeNil())
Expect(call0nth.NthParam(0)).To(Equal(3))
Expect(call0nth.NthParam(1)).To(Equal(-5))
}
func TestCallLastParams(t *testing.T) {
RegisterTestingT(t)
callLast := swapMock.NthCall(2)
Expect(callLast.NthParam(0)).To(Equal(13))
Expect(callLast.NthParam(1)).To(Equal(-17))
}