@@ -119,11 +119,6 @@ func (s *Subject) BarMethod(arg string) int {
119
119
return 0
120
120
}
121
121
122
- var (
123
- FooMethodType = reflect .TypeOf ((* Subject ).FooMethod )
124
- BarMethodType = reflect .TypeOf ((* Subject ).BarMethod )
125
- )
126
-
127
122
func assertEqual (t * testing.T , expected interface {}, actual interface {}) {
128
123
if ! reflect .DeepEqual (expected , actual ) {
129
124
t .Errorf ("Expected %+v, but got %+v" , expected , actual )
@@ -149,7 +144,7 @@ func TestExpectedMethodCall(t *testing.T) {
149
144
reporter , ctrl := createFixtures (t )
150
145
subject := new (Subject )
151
146
152
- ctrl .RecordCall (subject , "FooMethod" , FooMethodType , "argument" )
147
+ ctrl .RecordCall (subject , "FooMethod" , "argument" )
153
148
ctrl .Call (subject , "FooMethod" , "argument" )
154
149
ctrl .Finish ()
155
150
@@ -171,7 +166,7 @@ func TestRepeatedCall(t *testing.T) {
171
166
reporter , ctrl := createFixtures (t )
172
167
subject := new (Subject )
173
168
174
- ctrl .RecordCall (subject , "FooMethod" , FooMethodType , "argument" ).Times (3 )
169
+ ctrl .RecordCall (subject , "FooMethod" , "argument" ).Times (3 )
175
170
ctrl .Call (subject , "FooMethod" , "argument" )
176
171
ctrl .Call (subject , "FooMethod" , "argument" )
177
172
ctrl .Call (subject , "FooMethod" , "argument" )
@@ -188,7 +183,7 @@ func TestUnexpectedArgCount(t *testing.T) {
188
183
defer reporter .recoverUnexpectedFatal ()
189
184
subject := new (Subject )
190
185
191
- ctrl .RecordCall (subject , "FooMethod" , FooMethodType , "argument" )
186
+ ctrl .RecordCall (subject , "FooMethod" , "argument" )
192
187
reporter .assertFatal (func () {
193
188
// This call is made with the wrong number of arguments...
194
189
ctrl .Call (subject , "FooMethod" , "argument" , "extra_argument" )
@@ -207,7 +202,7 @@ func TestAnyTimes(t *testing.T) {
207
202
reporter , ctrl := createFixtures (t )
208
203
subject := new (Subject )
209
204
210
- ctrl .RecordCall (subject , "FooMethod" , FooMethodType , "argument" ).AnyTimes ()
205
+ ctrl .RecordCall (subject , "FooMethod" , "argument" ).AnyTimes ()
211
206
for i := 0 ; i < 100 ; i ++ {
212
207
ctrl .Call (subject , "FooMethod" , "argument" )
213
208
}
@@ -219,22 +214,22 @@ func TestMinTimes1(t *testing.T) {
219
214
// It fails if there are no calls
220
215
reporter , ctrl := createFixtures (t )
221
216
subject := new (Subject )
222
- ctrl .RecordCall (subject , "FooMethod" , FooMethodType , "argument" ).MinTimes (1 )
217
+ ctrl .RecordCall (subject , "FooMethod" , "argument" ).MinTimes (1 )
223
218
reporter .assertFatal (func () {
224
219
ctrl .Finish ()
225
220
})
226
221
227
222
// It succeeds if there is one call
228
223
reporter , ctrl = createFixtures (t )
229
224
subject = new (Subject )
230
- ctrl .RecordCall (subject , "FooMethod" , FooMethodType , "argument" ).MinTimes (1 )
225
+ ctrl .RecordCall (subject , "FooMethod" , "argument" ).MinTimes (1 )
231
226
ctrl .Call (subject , "FooMethod" , "argument" )
232
227
ctrl .Finish ()
233
228
234
229
// It succeeds if there are many calls
235
230
reporter , ctrl = createFixtures (t )
236
231
subject = new (Subject )
237
- ctrl .RecordCall (subject , "FooMethod" , FooMethodType , "argument" ).MinTimes (1 )
232
+ ctrl .RecordCall (subject , "FooMethod" , "argument" ).MinTimes (1 )
238
233
for i := 0 ; i < 100 ; i ++ {
239
234
ctrl .Call (subject , "FooMethod" , "argument" )
240
235
}
@@ -245,20 +240,20 @@ func TestMaxTimes1(t *testing.T) {
245
240
// It succeeds if there are no calls
246
241
_ , ctrl := createFixtures (t )
247
242
subject := new (Subject )
248
- ctrl .RecordCall (subject , "FooMethod" , FooMethodType , "argument" ).MaxTimes (1 )
243
+ ctrl .RecordCall (subject , "FooMethod" , "argument" ).MaxTimes (1 )
249
244
ctrl .Finish ()
250
245
251
246
// It succeeds if there is one call
252
247
_ , ctrl = createFixtures (t )
253
248
subject = new (Subject )
254
- ctrl .RecordCall (subject , "FooMethod" , FooMethodType , "argument" ).MaxTimes (1 )
249
+ ctrl .RecordCall (subject , "FooMethod" , "argument" ).MaxTimes (1 )
255
250
ctrl .Call (subject , "FooMethod" , "argument" )
256
251
ctrl .Finish ()
257
252
258
253
//It fails if there are more
259
254
reporter , ctrl := createFixtures (t )
260
255
subject = new (Subject )
261
- ctrl .RecordCall (subject , "FooMethod" , FooMethodType , "argument" ).MaxTimes (1 )
256
+ ctrl .RecordCall (subject , "FooMethod" , "argument" ).MaxTimes (1 )
262
257
ctrl .Call (subject , "FooMethod" , "argument" )
263
258
reporter .assertFatal (func () {
264
259
ctrl .Call (subject , "FooMethod" , "argument" )
@@ -270,7 +265,7 @@ func TestMinMaxTimes(t *testing.T) {
270
265
// It fails if there are less calls than specified
271
266
reporter , ctrl := createFixtures (t )
272
267
subject := new (Subject )
273
- ctrl .RecordCall (subject , "FooMethod" , FooMethodType , "argument" ).MinTimes (2 ).MaxTimes (2 )
268
+ ctrl .RecordCall (subject , "FooMethod" , "argument" ).MinTimes (2 ).MaxTimes (2 )
274
269
ctrl .Call (subject , "FooMethod" , "argument" )
275
270
reporter .assertFatal (func () {
276
271
ctrl .Finish ()
@@ -279,7 +274,7 @@ func TestMinMaxTimes(t *testing.T) {
279
274
// It fails if there are more calls than specified
280
275
reporter , ctrl = createFixtures (t )
281
276
subject = new (Subject )
282
- ctrl .RecordCall (subject , "FooMethod" , FooMethodType , "argument" ).MinTimes (2 ).MaxTimes (2 )
277
+ ctrl .RecordCall (subject , "FooMethod" , "argument" ).MinTimes (2 ).MaxTimes (2 )
283
278
ctrl .Call (subject , "FooMethod" , "argument" )
284
279
ctrl .Call (subject , "FooMethod" , "argument" )
285
280
reporter .assertFatal (func () {
@@ -289,7 +284,7 @@ func TestMinMaxTimes(t *testing.T) {
289
284
// It succeeds if there is just the right number of calls
290
285
reporter , ctrl = createFixtures (t )
291
286
subject = new (Subject )
292
- ctrl .RecordCall (subject , "FooMethod" , FooMethodType , "argument" ).MaxTimes (2 ).MinTimes (2 )
287
+ ctrl .RecordCall (subject , "FooMethod" , "argument" ).MaxTimes (2 ).MinTimes (2 )
293
288
ctrl .Call (subject , "FooMethod" , "argument" )
294
289
ctrl .Call (subject , "FooMethod" , "argument" )
295
290
ctrl .Finish ()
@@ -301,7 +296,7 @@ func TestDo(t *testing.T) {
301
296
302
297
doCalled := false
303
298
var argument string
304
- ctrl .RecordCall (subject , "FooMethod" , FooMethodType , "argument" ).Do (
299
+ ctrl .RecordCall (subject , "FooMethod" , "argument" ).Do (
305
300
func (arg string ) {
306
301
doCalled = true
307
302
argument = arg
@@ -327,8 +322,8 @@ func TestReturn(t *testing.T) {
327
322
subject := new (Subject )
328
323
329
324
// Unspecified return should produce "zero" result.
330
- ctrl .RecordCall (subject , "FooMethod" , FooMethodType , "zero" )
331
- ctrl .RecordCall (subject , "FooMethod" , FooMethodType , "five" ).Return (5 )
325
+ ctrl .RecordCall (subject , "FooMethod" , "zero" )
326
+ ctrl .RecordCall (subject , "FooMethod" , "five" ).Return (5 )
332
327
333
328
assertEqual (
334
329
t ,
@@ -348,10 +343,10 @@ func TestUnorderedCalls(t *testing.T) {
348
343
subjectTwo := new (Subject )
349
344
subjectOne := new (Subject )
350
345
351
- ctrl .RecordCall (subjectOne , "FooMethod" , FooMethodType , "1" )
352
- ctrl .RecordCall (subjectOne , "BarMethod" , BarMethodType , "2" )
353
- ctrl .RecordCall (subjectTwo , "FooMethod" , FooMethodType , "3" )
354
- ctrl .RecordCall (subjectTwo , "BarMethod" , BarMethodType , "4" )
346
+ ctrl .RecordCall (subjectOne , "FooMethod" , "1" )
347
+ ctrl .RecordCall (subjectOne , "BarMethod" , "2" )
348
+ ctrl .RecordCall (subjectTwo , "FooMethod" , "3" )
349
+ ctrl .RecordCall (subjectTwo , "BarMethod" , "4" )
355
350
356
351
// Make the calls in a different order, which should be fine.
357
352
ctrl .Call (subjectOne , "BarMethod" , "2" )
@@ -373,9 +368,9 @@ func commonTestOrderedCalls(t *testing.T) (reporter *ErrorReporter, ctrl *gomock
373
368
subjectTwo = new (Subject )
374
369
375
370
gomock .InOrder (
376
- ctrl .RecordCall (subjectOne , "FooMethod" , FooMethodType , "1" ).AnyTimes (),
377
- ctrl .RecordCall (subjectTwo , "FooMethod" , FooMethodType , "2" ),
378
- ctrl .RecordCall (subjectTwo , "BarMethod" , BarMethodType , "3" ),
371
+ ctrl .RecordCall (subjectOne , "FooMethod" , "1" ).AnyTimes (),
372
+ ctrl .RecordCall (subjectTwo , "FooMethod" , "2" ),
373
+ ctrl .RecordCall (subjectTwo , "BarMethod" , "3" ),
379
374
)
380
375
381
376
return
@@ -428,9 +423,9 @@ func TestCallAfterLoopPanic(t *testing.T) {
428
423
429
424
subject := new (Subject )
430
425
431
- firstCall := ctrl .RecordCall (subject , "FooMethod" , FooMethodType , "1" )
432
- secondCall := ctrl .RecordCall (subject , "FooMethod" , FooMethodType , "2" )
433
- thirdCall := ctrl .RecordCall (subject , "FooMethod" , FooMethodType , "3" )
426
+ firstCall := ctrl .RecordCall (subject , "FooMethod" , "1" )
427
+ secondCall := ctrl .RecordCall (subject , "FooMethod" , "2" )
428
+ thirdCall := ctrl .RecordCall (subject , "FooMethod" , "3" )
434
429
435
430
gomock .InOrder (firstCall , secondCall , thirdCall )
436
431
@@ -450,7 +445,7 @@ func TestPanicOverridesExpectationChecks(t *testing.T) {
450
445
reporter := NewErrorReporter (t )
451
446
452
447
reporter .assertFatal (func () {
453
- ctrl .RecordCall (new (Subject ), "FooMethod" , FooMethodType , "1" )
448
+ ctrl .RecordCall (new (Subject ), "FooMethod" , "1" )
454
449
defer ctrl .Finish ()
455
450
reporter .Fatalf ("Intentional panic" )
456
451
})
@@ -463,7 +458,7 @@ func TestSetArgWithBadType(t *testing.T) {
463
458
s := new (Subject )
464
459
// This should catch a type error:
465
460
rep .assertFatal (func () {
466
- ctrl .RecordCall (s , "FooMethod" , FooMethodType , "1" ).SetArg (0 , "blah" )
461
+ ctrl .RecordCall (s , "FooMethod" , "1" ).SetArg (0 , "blah" )
467
462
})
468
463
ctrl .Call (s , "FooMethod" , "1" )
469
464
}
@@ -473,7 +468,7 @@ func TestTimes0(t *testing.T) {
473
468
defer ctrl .Finish ()
474
469
475
470
s := new (Subject )
476
- ctrl .RecordCall (s , "FooMethod" , FooMethodType , "arg" ).Times (0 )
471
+ ctrl .RecordCall (s , "FooMethod" , "arg" ).Times (0 )
477
472
rep .assertFatal (func () {
478
473
ctrl .Call (s , "FooMethod" , "arg" )
479
474
})
0 commit comments