-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils_test.go
54 lines (47 loc) · 1.16 KB
/
utils_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 mmock
import (
"errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"testing"
)
func TestAs(t *testing.T) {
args := mock.Arguments{"a", 16, errors.New("")}
a0 := As[string](args, 0)
assert.Equal(t, "a", a0)
a1 := As[int](args, 1)
assert.Equal(t, 16, a1)
a2 := As[error](args, 2)
assert.Error(t, a2)
args = mock.Arguments{nil}
aa := As[any](args, 0)
assert.Nil(t, aa)
as := As[string](args, 0)
assert.Equal(t, "", as)
}
func TestAs1(t *testing.T) {
args := mock.Arguments{errors.New("")}
a0 := As1[error](args)
assert.Error(t, a0)
}
func TestAs2(t *testing.T) {
args := mock.Arguments{"a", errors.New("")}
a0, a1 := As2[string, error](args)
assert.Equal(t, "a", a0)
assert.Error(t, a1)
}
func TestAs3(t *testing.T) {
args := mock.Arguments{"a", 16, errors.New("")}
a0, a1, a2 := As3[string, int, error](args)
assert.Equal(t, "a", a0)
assert.Equal(t, 16, a1)
assert.Error(t, a2)
}
func TestAs4(t *testing.T) {
args := mock.Arguments{"a", 16, errors.New(""), true}
a0, a1, a2, a3 := As4[string, int, error, bool](args)
assert.Equal(t, "a", a0)
assert.Equal(t, 16, a1)
assert.Error(t, a2)
assert.True(t, a3)
}