@@ -54,19 +54,67 @@ func Test_NotEqualShouldFail_WhenActualMatchesExpected(t *testing.T) {
54
54
}
55
55
}
56
56
57
- func Test_NilShouldPass_GivenNilValue (t * testing.T ) {
57
+ func Test_NilShouldPass_GivenNilPointer (t * testing.T ) {
58
58
tester := new (testing.T )
59
59
60
60
var valuePtr * string = nil
61
61
62
62
Nil (tester , valuePtr )
63
63
64
64
if tester .Failed () {
65
- t .Error ("Nil did not pass when nil value was given" )
65
+ t .Error ("Nil did not pass when nil pointer was given" )
66
66
}
67
67
}
68
68
69
- func Test_NilShouldFail_GivenNonNilValue (t * testing.T ) {
69
+ func Test_NilShouldPass_GivenNilMap (t * testing.T ) {
70
+ tester := new (testing.T )
71
+
72
+ var nilMap map [int ]int = nil
73
+
74
+ Nil (tester , nilMap )
75
+
76
+ if tester .Failed () {
77
+ t .Error ("Nil did not pass when nil map was given" )
78
+ }
79
+ }
80
+
81
+ func Test_NilShouldPass_GivenNilSlice (t * testing.T ) {
82
+ tester := new (testing.T )
83
+
84
+ var nilSlice []int = nil
85
+
86
+ Nil (tester , nilSlice )
87
+
88
+ if tester .Failed () {
89
+ t .Error ("Nil did not pass when nil slice was given" )
90
+ }
91
+ }
92
+
93
+ func Test_NilShouldPass_GivenNilChannel (t * testing.T ) {
94
+ tester := new (testing.T )
95
+
96
+ var nilChan chan int = nil
97
+
98
+ Nil (tester , nilChan )
99
+
100
+ if tester .Failed () {
101
+ t .Error ("Nil did not pass when nil channel was given" )
102
+ }
103
+ }
104
+
105
+ func Test_NilShouldPass_GivenNilFunction (t * testing.T ) {
106
+ tester := new (testing.T )
107
+
108
+ var nilFunc func () = nil
109
+
110
+ Nil (tester , nilFunc )
111
+
112
+ if tester .Failed () {
113
+ t .Error ("Nil did not pass when nil function was given" )
114
+ }
115
+ }
116
+
117
+ func Test_NilShouldFail_GivenNonNilPointer (t * testing.T ) {
70
118
tester := new (testing.T )
71
119
72
120
value := "value"
@@ -79,7 +127,55 @@ func Test_NilShouldFail_GivenNonNilValue(t *testing.T) {
79
127
}
80
128
}
81
129
82
- func Test_NotNilShouldPass_GivenNonNilValue (t * testing.T ) {
130
+ func Test_NilShouldFail_GivenNonNilMap (t * testing.T ) {
131
+ tester := new (testing.T )
132
+
133
+ nonNilMap := make (map [int ]int , 0 )
134
+
135
+ Nil (tester , nonNilMap )
136
+
137
+ if ! tester .Failed () {
138
+ t .Error ("Nil did not fail when non-nil map was given" )
139
+ }
140
+ }
141
+
142
+ func Test_NilShouldFail_GivenNonNilSlice (t * testing.T ) {
143
+ tester := new (testing.T )
144
+
145
+ nonNilSlice := []int {10 }
146
+
147
+ Nil (tester , nonNilSlice )
148
+
149
+ if ! tester .Failed () {
150
+ t .Error ("Nil did not fail when non-nil slice was given" )
151
+ }
152
+ }
153
+
154
+ func Test_NilShouldFail_GivenNonNilChannel (t * testing.T ) {
155
+ tester := new (testing.T )
156
+
157
+ nonNilChan := make (chan int )
158
+
159
+ Nil (tester , nonNilChan )
160
+
161
+ if ! tester .Failed () {
162
+ t .Error ("Nil did not fail when non-nil channel was given" )
163
+ }
164
+ }
165
+
166
+ func Test_NilShouldFail_GivenNonNilFunction (t * testing.T ) {
167
+ tester := new (testing.T )
168
+
169
+ nonNilFunc := func () {}
170
+
171
+ Nil (tester , nonNilFunc )
172
+
173
+ if ! tester .Failed () {
174
+ t .Error ("Nil did not fail when non-nil function was given" )
175
+ }
176
+ }
177
+
178
+ func Test_NotNilShouldPass_GivenNonNilPointer (t * testing.T ) {
83
179
tester := new (testing.T )
84
180
85
181
value := "value"
@@ -88,19 +184,115 @@ func Test_NotNilShouldPass_GivenNonNilValue(t *testing.T) {
88
184
NotNil (tester , valuePtr )
89
185
90
186
if tester .Failed () {
91
- t .Error ("NotNil did not pass when non-nil value was given" )
187
+ t .Error ("NotNil did not pass when non-nil pointer was given" )
92
188
}
93
189
}
94
190
95
- func Test_NotNilShouldFail_GivenNilValue (t * testing.T ) {
191
+ func Test_NotNilShouldPass_GivenNonNilMap (t * testing.T ) {
192
+ tester := new (testing.T )
193
+
194
+ nonNilMap := make (map [int ]int , 0 )
195
+
196
+ NotNil (tester , nonNilMap )
197
+
198
+ if tester .Failed () {
199
+ t .Error ("NotNil did not pass when non-nil map was given" )
200
+ }
201
+ }
202
+
203
+ func Test_NotNilShouldPass_GivenNonNilSlice (t * testing.T ) {
204
+ tester := new (testing.T )
205
+
206
+ nonNilSlice := []int {10 }
207
+
208
+ NotNil (tester , nonNilSlice )
209
+
210
+ if tester .Failed () {
211
+ t .Error ("NotNil did not pass when non-nil slice was given" )
212
+ }
213
+ }
214
+
215
+ func Test_NotNilShouldPass_GivenNonNilChan (t * testing.T ) {
216
+ tester := new (testing.T )
217
+
218
+ nonNilChan := make (chan int )
219
+
220
+ NotNil (tester , nonNilChan )
221
+
222
+ if tester .Failed () {
223
+ t .Error ("NotNil did not pass when non-nil channel was given" )
224
+ }
225
+ }
226
+
227
+ func Test_NotNilShouldPass_GivenNonNilFunction (t * testing.T ) {
228
+ tester := new (testing.T )
229
+
230
+ nonNilFunc := func () {}
231
+
232
+ NotNil (tester , nonNilFunc )
233
+
234
+ if tester .Failed () {
235
+ t .Error ("NotNil did not pass when non-nil function was given" )
236
+ }
237
+ }
238
+
239
+ func Test_NotNilShouldFail_GivenNilPointer (t * testing.T ) {
96
240
tester := new (testing.T )
97
241
98
242
var valuePtr * string = nil
99
243
100
244
NotNil (tester , valuePtr )
101
245
102
246
if ! tester .Failed () {
103
- t .Error ("NotNil did not fail when nil value was given" )
247
+ t .Error ("NotNil did not fail when nil pointer was given" )
248
+ }
249
+ }
250
+
251
+ func Test_NotNilShouldFail_GivenNilMap (t * testing.T ) {
252
+ tester := new (testing.T )
253
+
254
+ var nilMap map [int ]int = nil
255
+
256
+ NotNil (tester , nilMap )
257
+
258
+ if ! tester .Failed () {
259
+ t .Error ("NotNil did not fail when nil map was given" )
260
+ }
261
+ }
262
+
263
+ func Test_NotNilShouldFail_GivenNilSlice (t * testing.T ) {
264
+ tester := new (testing.T )
265
+
266
+ var nilSlice []int = nil
267
+
268
+ NotNil (tester , nilSlice )
269
+
270
+ if ! tester .Failed () {
271
+ t .Error ("NotNil did not fail when nil slice was given" )
272
+ }
273
+ }
274
+
275
+ func Test_NotNilShouldFail_GivenNilChannel (t * testing.T ) {
276
+ tester := new (testing.T )
277
+
278
+ var nilChan chan int = nil
279
+
280
+ NotNil (tester , nilChan )
281
+
282
+ if ! tester .Failed () {
283
+ t .Error ("NotNil did not fail when nil channel was given" )
284
+ }
285
+ }
286
+
287
+ func Test_NotNilShouldFail_GivenNilFunction (t * testing.T ) {
288
+ tester := new (testing.T )
289
+
290
+ var nilFunc func () = nil
291
+
292
+ NotNil (tester , nilFunc )
293
+
294
+ if ! tester .Failed () {
295
+ t .Error ("NotNil did not fail when nil function was given" )
104
296
}
105
297
}
106
298
0 commit comments