-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontext_test.go
132 lines (97 loc) · 2.43 KB
/
context_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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package injector
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNew(t *testing.T) {
t.Parallel()
ctx := New()
assert.NotNil(t, ctx.namedProvided)
assert.NotNil(t, ctx.typesProvided)
assert.Empty(t, ctx.typesProvided)
assert.Empty(t, ctx.namedProvided)
}
func TestContext_Provide_Bool(t *testing.T) {
t.Parallel()
ctx := New()
ctx.Provide(bool(true))
assert.NotNil(t, ctx.typesProvided["bool"])
}
func TestContext_Provide_String(t *testing.T) {
t.Parallel()
ctx := New()
ctx.Provide(string("Hello world"))
assert.NotNil(t, ctx.typesProvided["string"])
}
func TestContext_Provide_Int(t *testing.T) {
t.Parallel()
ctx := New()
ctx.Provide(int(1))
assert.NotNil(t, ctx.typesProvided["int"])
ctx = New()
ctx.Provide(int8(1))
assert.NotNil(t, ctx.typesProvided["int8"])
ctx = New()
ctx.Provide(int16(1))
assert.NotNil(t, ctx.typesProvided["int16"])
ctx = New()
ctx.Provide(int32(1))
assert.NotNil(t, ctx.typesProvided["int32"])
ctx = New()
ctx.Provide(int64(1))
assert.NotNil(t, ctx.typesProvided["int64"])
}
func TestContext_Provide_Uint(t *testing.T) {
t.Parallel()
ctx := New()
ctx.Provide(uint(1))
assert.NotNil(t, ctx.typesProvided["uint"])
ctx = New()
ctx.Provide(uint8(1))
assert.NotNil(t, ctx.typesProvided["uint8"])
ctx = New()
ctx.Provide(uint16(1))
assert.NotNil(t, ctx.typesProvided["uint16"])
ctx = New()
ctx.Provide(uint32(1))
assert.NotNil(t, ctx.typesProvided["uint32"])
ctx = New()
ctx.Provide(uint64(1))
assert.NotNil(t, ctx.typesProvided["uint64"])
ctx = New()
ctx.Provide(uintptr(1))
assert.NotNil(t, ctx.typesProvided["uintptr"])
}
func TestContext_Provide_Float(t *testing.T) {
t.Parallel()
ctx := New()
ctx.Provide(float32(1))
assert.NotNil(t, ctx.typesProvided["float32"])
ctx = New()
ctx.Provide(float64(1))
assert.NotNil(t, ctx.typesProvided["float64"])
}
func TestContext_Provide_Byte(t *testing.T) {
t.Parallel()
ctx := New()
ctx.Provide(byte(1))
assert.NotNil(t, ctx.typesProvided["uint8"])
}
func TestContext_Provide_Rune(t *testing.T) {
t.Parallel()
ctx := New()
ctx.Provide(rune(1))
assert.NotNil(t, ctx.typesProvided["int32"])
}
func TestContext_Provide_Complex(t *testing.T) {
t.Parallel()
ctx := New()
ctx.Provide(complex64(1))
assert.NotNil(t, ctx.typesProvided["complex64"])
ctx = New()
ctx.Provide(complex128(1))
assert.NotNil(t, ctx.typesProvided["complex128"])
}
func TestContext_Provide_Struct(t *testing.T) {
t.Parallel()
}