-
Notifications
You must be signed in to change notification settings - Fork 0
/
fixed_reader_mock.go
972 lines (800 loc) · 33.1 KB
/
fixed_reader_mock.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
package longbits
// Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT.
import (
"io"
"sync"
mm_atomic "sync/atomic"
mm_time "time"
"github.com/gojuno/minimock"
)
// FixedReaderMock implements FixedReader
type FixedReaderMock struct {
t minimock.Tester
funcAsByteString func() (b1 ByteString)
inspectFuncAsByteString func()
afterAsByteStringCounter uint64
beforeAsByteStringCounter uint64
AsByteStringMock mFixedReaderMockAsByteString
funcAsBytes func() (ba1 []byte)
inspectFuncAsBytes func()
afterAsBytesCounter uint64
beforeAsBytesCounter uint64
AsBytesMock mFixedReaderMockAsBytes
funcFixedByteSize func() (i1 int)
inspectFuncFixedByteSize func()
afterFixedByteSizeCounter uint64
beforeFixedByteSizeCounter uint64
FixedByteSizeMock mFixedReaderMockFixedByteSize
funcRead func(p []byte) (n int, err error)
inspectFuncRead func(p []byte)
afterReadCounter uint64
beforeReadCounter uint64
ReadMock mFixedReaderMockRead
funcWriteTo func(w io.Writer) (n int64, err error)
inspectFuncWriteTo func(w io.Writer)
afterWriteToCounter uint64
beforeWriteToCounter uint64
WriteToMock mFixedReaderMockWriteTo
}
// NewFixedReaderMock returns a mock for FixedReader
func NewFixedReaderMock(t minimock.Tester) *FixedReaderMock {
m := &FixedReaderMock{t: t}
if controller, ok := t.(minimock.MockController); ok {
controller.RegisterMocker(m)
}
m.AsByteStringMock = mFixedReaderMockAsByteString{mock: m}
m.AsBytesMock = mFixedReaderMockAsBytes{mock: m}
m.FixedByteSizeMock = mFixedReaderMockFixedByteSize{mock: m}
m.ReadMock = mFixedReaderMockRead{mock: m}
m.ReadMock.callArgs = []*FixedReaderMockReadParams{}
m.WriteToMock = mFixedReaderMockWriteTo{mock: m}
m.WriteToMock.callArgs = []*FixedReaderMockWriteToParams{}
return m
}
type mFixedReaderMockAsByteString struct {
mock *FixedReaderMock
defaultExpectation *FixedReaderMockAsByteStringExpectation
expectations []*FixedReaderMockAsByteStringExpectation
}
// FixedReaderMockAsByteStringExpectation specifies expectation struct of the FixedReader.AsByteString
type FixedReaderMockAsByteStringExpectation struct {
mock *FixedReaderMock
results *FixedReaderMockAsByteStringResults
Counter uint64
}
// FixedReaderMockAsByteStringResults contains results of the FixedReader.AsByteString
type FixedReaderMockAsByteStringResults struct {
b1 ByteString
}
// Expect sets up expected params for FixedReader.AsByteString
func (mmAsByteString *mFixedReaderMockAsByteString) Expect() *mFixedReaderMockAsByteString {
if mmAsByteString.mock.funcAsByteString != nil {
mmAsByteString.mock.t.Fatalf("FixedReaderMock.AsByteString mock is already set by Set")
}
if mmAsByteString.defaultExpectation == nil {
mmAsByteString.defaultExpectation = &FixedReaderMockAsByteStringExpectation{}
}
return mmAsByteString
}
// Inspect accepts an inspector function that has same arguments as the FixedReader.AsByteString
func (mmAsByteString *mFixedReaderMockAsByteString) Inspect(f func()) *mFixedReaderMockAsByteString {
if mmAsByteString.mock.inspectFuncAsByteString != nil {
mmAsByteString.mock.t.Fatalf("Inspect function is already set for FixedReaderMock.AsByteString")
}
mmAsByteString.mock.inspectFuncAsByteString = f
return mmAsByteString
}
// Return sets up results that will be returned by FixedReader.AsByteString
func (mmAsByteString *mFixedReaderMockAsByteString) Return(b1 ByteString) *FixedReaderMock {
if mmAsByteString.mock.funcAsByteString != nil {
mmAsByteString.mock.t.Fatalf("FixedReaderMock.AsByteString mock is already set by Set")
}
if mmAsByteString.defaultExpectation == nil {
mmAsByteString.defaultExpectation = &FixedReaderMockAsByteStringExpectation{mock: mmAsByteString.mock}
}
mmAsByteString.defaultExpectation.results = &FixedReaderMockAsByteStringResults{b1}
return mmAsByteString.mock
}
//Set uses given function f to mock the FixedReader.AsByteString method
func (mmAsByteString *mFixedReaderMockAsByteString) Set(f func() (b1 ByteString)) *FixedReaderMock {
if mmAsByteString.defaultExpectation != nil {
mmAsByteString.mock.t.Fatalf("Default expectation is already set for the FixedReader.AsByteString method")
}
if len(mmAsByteString.expectations) > 0 {
mmAsByteString.mock.t.Fatalf("Some expectations are already set for the FixedReader.AsByteString method")
}
mmAsByteString.mock.funcAsByteString = f
return mmAsByteString.mock
}
// AsByteString implements FixedReader
func (mmAsByteString *FixedReaderMock) AsByteString() (b1 ByteString) {
mm_atomic.AddUint64(&mmAsByteString.beforeAsByteStringCounter, 1)
defer mm_atomic.AddUint64(&mmAsByteString.afterAsByteStringCounter, 1)
if mmAsByteString.inspectFuncAsByteString != nil {
mmAsByteString.inspectFuncAsByteString()
}
if mmAsByteString.AsByteStringMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmAsByteString.AsByteStringMock.defaultExpectation.Counter, 1)
results := mmAsByteString.AsByteStringMock.defaultExpectation.results
if results == nil {
mmAsByteString.t.Fatal("No results are set for the FixedReaderMock.AsByteString")
}
return (*results).b1
}
if mmAsByteString.funcAsByteString != nil {
return mmAsByteString.funcAsByteString()
}
mmAsByteString.t.Fatalf("Unexpected call to FixedReaderMock.AsByteString.")
return
}
// AsByteStringAfterCounter returns a count of finished FixedReaderMock.AsByteString invocations
func (mmAsByteString *FixedReaderMock) AsByteStringAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmAsByteString.afterAsByteStringCounter)
}
// AsByteStringBeforeCounter returns a count of FixedReaderMock.AsByteString invocations
func (mmAsByteString *FixedReaderMock) AsByteStringBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmAsByteString.beforeAsByteStringCounter)
}
// MinimockAsByteStringDone returns true if the count of the AsByteString invocations corresponds
// the number of defined expectations
func (m *FixedReaderMock) MinimockAsByteStringDone() bool {
for _, e := range m.AsByteStringMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
return false
}
}
// if default expectation was set then invocations count should be greater than zero
if m.AsByteStringMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterAsByteStringCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcAsByteString != nil && mm_atomic.LoadUint64(&m.afterAsByteStringCounter) < 1 {
return false
}
return true
}
// MinimockAsByteStringInspect logs each unmet expectation
func (m *FixedReaderMock) MinimockAsByteStringInspect() {
for _, e := range m.AsByteStringMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Error("Expected call to FixedReaderMock.AsByteString")
}
}
// if default expectation was set then invocations count should be greater than zero
if m.AsByteStringMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterAsByteStringCounter) < 1 {
m.t.Error("Expected call to FixedReaderMock.AsByteString")
}
// if func was set then invocations count should be greater than zero
if m.funcAsByteString != nil && mm_atomic.LoadUint64(&m.afterAsByteStringCounter) < 1 {
m.t.Error("Expected call to FixedReaderMock.AsByteString")
}
}
type mFixedReaderMockAsBytes struct {
mock *FixedReaderMock
defaultExpectation *FixedReaderMockAsBytesExpectation
expectations []*FixedReaderMockAsBytesExpectation
}
// FixedReaderMockAsBytesExpectation specifies expectation struct of the FixedReader.AsBytes
type FixedReaderMockAsBytesExpectation struct {
mock *FixedReaderMock
results *FixedReaderMockAsBytesResults
Counter uint64
}
// FixedReaderMockAsBytesResults contains results of the FixedReader.AsBytes
type FixedReaderMockAsBytesResults struct {
ba1 []byte
}
// Expect sets up expected params for FixedReader.AsBytes
func (mmAsBytes *mFixedReaderMockAsBytes) Expect() *mFixedReaderMockAsBytes {
if mmAsBytes.mock.funcAsBytes != nil {
mmAsBytes.mock.t.Fatalf("FixedReaderMock.AsBytes mock is already set by Set")
}
if mmAsBytes.defaultExpectation == nil {
mmAsBytes.defaultExpectation = &FixedReaderMockAsBytesExpectation{}
}
return mmAsBytes
}
// Inspect accepts an inspector function that has same arguments as the FixedReader.AsBytes
func (mmAsBytes *mFixedReaderMockAsBytes) Inspect(f func()) *mFixedReaderMockAsBytes {
if mmAsBytes.mock.inspectFuncAsBytes != nil {
mmAsBytes.mock.t.Fatalf("Inspect function is already set for FixedReaderMock.AsBytes")
}
mmAsBytes.mock.inspectFuncAsBytes = f
return mmAsBytes
}
// Return sets up results that will be returned by FixedReader.AsBytes
func (mmAsBytes *mFixedReaderMockAsBytes) Return(ba1 []byte) *FixedReaderMock {
if mmAsBytes.mock.funcAsBytes != nil {
mmAsBytes.mock.t.Fatalf("FixedReaderMock.AsBytes mock is already set by Set")
}
if mmAsBytes.defaultExpectation == nil {
mmAsBytes.defaultExpectation = &FixedReaderMockAsBytesExpectation{mock: mmAsBytes.mock}
}
mmAsBytes.defaultExpectation.results = &FixedReaderMockAsBytesResults{ba1}
return mmAsBytes.mock
}
//Set uses given function f to mock the FixedReader.AsBytes method
func (mmAsBytes *mFixedReaderMockAsBytes) Set(f func() (ba1 []byte)) *FixedReaderMock {
if mmAsBytes.defaultExpectation != nil {
mmAsBytes.mock.t.Fatalf("Default expectation is already set for the FixedReader.AsBytes method")
}
if len(mmAsBytes.expectations) > 0 {
mmAsBytes.mock.t.Fatalf("Some expectations are already set for the FixedReader.AsBytes method")
}
mmAsBytes.mock.funcAsBytes = f
return mmAsBytes.mock
}
// AsBytes implements FixedReader
func (mmAsBytes *FixedReaderMock) AsBytes() (ba1 []byte) {
mm_atomic.AddUint64(&mmAsBytes.beforeAsBytesCounter, 1)
defer mm_atomic.AddUint64(&mmAsBytes.afterAsBytesCounter, 1)
if mmAsBytes.inspectFuncAsBytes != nil {
mmAsBytes.inspectFuncAsBytes()
}
if mmAsBytes.AsBytesMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmAsBytes.AsBytesMock.defaultExpectation.Counter, 1)
results := mmAsBytes.AsBytesMock.defaultExpectation.results
if results == nil {
mmAsBytes.t.Fatal("No results are set for the FixedReaderMock.AsBytes")
}
return (*results).ba1
}
if mmAsBytes.funcAsBytes != nil {
return mmAsBytes.funcAsBytes()
}
mmAsBytes.t.Fatalf("Unexpected call to FixedReaderMock.AsBytes.")
return
}
// AsBytesAfterCounter returns a count of finished FixedReaderMock.AsBytes invocations
func (mmAsBytes *FixedReaderMock) AsBytesAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmAsBytes.afterAsBytesCounter)
}
// AsBytesBeforeCounter returns a count of FixedReaderMock.AsBytes invocations
func (mmAsBytes *FixedReaderMock) AsBytesBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmAsBytes.beforeAsBytesCounter)
}
// MinimockAsBytesDone returns true if the count of the AsBytes invocations corresponds
// the number of defined expectations
func (m *FixedReaderMock) MinimockAsBytesDone() bool {
for _, e := range m.AsBytesMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
return false
}
}
// if default expectation was set then invocations count should be greater than zero
if m.AsBytesMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterAsBytesCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcAsBytes != nil && mm_atomic.LoadUint64(&m.afterAsBytesCounter) < 1 {
return false
}
return true
}
// MinimockAsBytesInspect logs each unmet expectation
func (m *FixedReaderMock) MinimockAsBytesInspect() {
for _, e := range m.AsBytesMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Error("Expected call to FixedReaderMock.AsBytes")
}
}
// if default expectation was set then invocations count should be greater than zero
if m.AsBytesMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterAsBytesCounter) < 1 {
m.t.Error("Expected call to FixedReaderMock.AsBytes")
}
// if func was set then invocations count should be greater than zero
if m.funcAsBytes != nil && mm_atomic.LoadUint64(&m.afterAsBytesCounter) < 1 {
m.t.Error("Expected call to FixedReaderMock.AsBytes")
}
}
type mFixedReaderMockFixedByteSize struct {
mock *FixedReaderMock
defaultExpectation *FixedReaderMockFixedByteSizeExpectation
expectations []*FixedReaderMockFixedByteSizeExpectation
}
// FixedReaderMockFixedByteSizeExpectation specifies expectation struct of the FixedReader.FixedByteSize
type FixedReaderMockFixedByteSizeExpectation struct {
mock *FixedReaderMock
results *FixedReaderMockFixedByteSizeResults
Counter uint64
}
// FixedReaderMockFixedByteSizeResults contains results of the FixedReader.FixedByteSize
type FixedReaderMockFixedByteSizeResults struct {
i1 int
}
// Expect sets up expected params for FixedReader.FixedByteSize
func (mmFixedByteSize *mFixedReaderMockFixedByteSize) Expect() *mFixedReaderMockFixedByteSize {
if mmFixedByteSize.mock.funcFixedByteSize != nil {
mmFixedByteSize.mock.t.Fatalf("FixedReaderMock.FixedByteSize mock is already set by Set")
}
if mmFixedByteSize.defaultExpectation == nil {
mmFixedByteSize.defaultExpectation = &FixedReaderMockFixedByteSizeExpectation{}
}
return mmFixedByteSize
}
// Inspect accepts an inspector function that has same arguments as the FixedReader.FixedByteSize
func (mmFixedByteSize *mFixedReaderMockFixedByteSize) Inspect(f func()) *mFixedReaderMockFixedByteSize {
if mmFixedByteSize.mock.inspectFuncFixedByteSize != nil {
mmFixedByteSize.mock.t.Fatalf("Inspect function is already set for FixedReaderMock.FixedByteSize")
}
mmFixedByteSize.mock.inspectFuncFixedByteSize = f
return mmFixedByteSize
}
// Return sets up results that will be returned by FixedReader.FixedByteSize
func (mmFixedByteSize *mFixedReaderMockFixedByteSize) Return(i1 int) *FixedReaderMock {
if mmFixedByteSize.mock.funcFixedByteSize != nil {
mmFixedByteSize.mock.t.Fatalf("FixedReaderMock.FixedByteSize mock is already set by Set")
}
if mmFixedByteSize.defaultExpectation == nil {
mmFixedByteSize.defaultExpectation = &FixedReaderMockFixedByteSizeExpectation{mock: mmFixedByteSize.mock}
}
mmFixedByteSize.defaultExpectation.results = &FixedReaderMockFixedByteSizeResults{i1}
return mmFixedByteSize.mock
}
//Set uses given function f to mock the FixedReader.FixedByteSize method
func (mmFixedByteSize *mFixedReaderMockFixedByteSize) Set(f func() (i1 int)) *FixedReaderMock {
if mmFixedByteSize.defaultExpectation != nil {
mmFixedByteSize.mock.t.Fatalf("Default expectation is already set for the FixedReader.FixedByteSize method")
}
if len(mmFixedByteSize.expectations) > 0 {
mmFixedByteSize.mock.t.Fatalf("Some expectations are already set for the FixedReader.FixedByteSize method")
}
mmFixedByteSize.mock.funcFixedByteSize = f
return mmFixedByteSize.mock
}
// FixedByteSize implements FixedReader
func (mmFixedByteSize *FixedReaderMock) FixedByteSize() (i1 int) {
mm_atomic.AddUint64(&mmFixedByteSize.beforeFixedByteSizeCounter, 1)
defer mm_atomic.AddUint64(&mmFixedByteSize.afterFixedByteSizeCounter, 1)
if mmFixedByteSize.inspectFuncFixedByteSize != nil {
mmFixedByteSize.inspectFuncFixedByteSize()
}
if mmFixedByteSize.FixedByteSizeMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmFixedByteSize.FixedByteSizeMock.defaultExpectation.Counter, 1)
results := mmFixedByteSize.FixedByteSizeMock.defaultExpectation.results
if results == nil {
mmFixedByteSize.t.Fatal("No results are set for the FixedReaderMock.FixedByteSize")
}
return (*results).i1
}
if mmFixedByteSize.funcFixedByteSize != nil {
return mmFixedByteSize.funcFixedByteSize()
}
mmFixedByteSize.t.Fatalf("Unexpected call to FixedReaderMock.FixedByteSize.")
return
}
// FixedByteSizeAfterCounter returns a count of finished FixedReaderMock.FixedByteSize invocations
func (mmFixedByteSize *FixedReaderMock) FixedByteSizeAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmFixedByteSize.afterFixedByteSizeCounter)
}
// FixedByteSizeBeforeCounter returns a count of FixedReaderMock.FixedByteSize invocations
func (mmFixedByteSize *FixedReaderMock) FixedByteSizeBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmFixedByteSize.beforeFixedByteSizeCounter)
}
// MinimockFixedByteSizeDone returns true if the count of the FixedByteSize invocations corresponds
// the number of defined expectations
func (m *FixedReaderMock) MinimockFixedByteSizeDone() bool {
for _, e := range m.FixedByteSizeMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
return false
}
}
// if default expectation was set then invocations count should be greater than zero
if m.FixedByteSizeMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterFixedByteSizeCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcFixedByteSize != nil && mm_atomic.LoadUint64(&m.afterFixedByteSizeCounter) < 1 {
return false
}
return true
}
// MinimockFixedByteSizeInspect logs each unmet expectation
func (m *FixedReaderMock) MinimockFixedByteSizeInspect() {
for _, e := range m.FixedByteSizeMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Error("Expected call to FixedReaderMock.FixedByteSize")
}
}
// if default expectation was set then invocations count should be greater than zero
if m.FixedByteSizeMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterFixedByteSizeCounter) < 1 {
m.t.Error("Expected call to FixedReaderMock.FixedByteSize")
}
// if func was set then invocations count should be greater than zero
if m.funcFixedByteSize != nil && mm_atomic.LoadUint64(&m.afterFixedByteSizeCounter) < 1 {
m.t.Error("Expected call to FixedReaderMock.FixedByteSize")
}
}
type mFixedReaderMockRead struct {
mock *FixedReaderMock
defaultExpectation *FixedReaderMockReadExpectation
expectations []*FixedReaderMockReadExpectation
callArgs []*FixedReaderMockReadParams
mutex sync.RWMutex
}
// FixedReaderMockReadExpectation specifies expectation struct of the FixedReader.Read
type FixedReaderMockReadExpectation struct {
mock *FixedReaderMock
params *FixedReaderMockReadParams
results *FixedReaderMockReadResults
Counter uint64
}
// FixedReaderMockReadParams contains parameters of the FixedReader.Read
type FixedReaderMockReadParams struct {
p []byte
}
// FixedReaderMockReadResults contains results of the FixedReader.Read
type FixedReaderMockReadResults struct {
n int
err error
}
// Expect sets up expected params for FixedReader.Read
func (mmRead *mFixedReaderMockRead) Expect(p []byte) *mFixedReaderMockRead {
if mmRead.mock.funcRead != nil {
mmRead.mock.t.Fatalf("FixedReaderMock.Read mock is already set by Set")
}
if mmRead.defaultExpectation == nil {
mmRead.defaultExpectation = &FixedReaderMockReadExpectation{}
}
mmRead.defaultExpectation.params = &FixedReaderMockReadParams{p}
for _, e := range mmRead.expectations {
if minimock.Equal(e.params, mmRead.defaultExpectation.params) {
mmRead.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmRead.defaultExpectation.params)
}
}
return mmRead
}
// Inspect accepts an inspector function that has same arguments as the FixedReader.Read
func (mmRead *mFixedReaderMockRead) Inspect(f func(p []byte)) *mFixedReaderMockRead {
if mmRead.mock.inspectFuncRead != nil {
mmRead.mock.t.Fatalf("Inspect function is already set for FixedReaderMock.Read")
}
mmRead.mock.inspectFuncRead = f
return mmRead
}
// Return sets up results that will be returned by FixedReader.Read
func (mmRead *mFixedReaderMockRead) Return(n int, err error) *FixedReaderMock {
if mmRead.mock.funcRead != nil {
mmRead.mock.t.Fatalf("FixedReaderMock.Read mock is already set by Set")
}
if mmRead.defaultExpectation == nil {
mmRead.defaultExpectation = &FixedReaderMockReadExpectation{mock: mmRead.mock}
}
mmRead.defaultExpectation.results = &FixedReaderMockReadResults{n, err}
return mmRead.mock
}
//Set uses given function f to mock the FixedReader.Read method
func (mmRead *mFixedReaderMockRead) Set(f func(p []byte) (n int, err error)) *FixedReaderMock {
if mmRead.defaultExpectation != nil {
mmRead.mock.t.Fatalf("Default expectation is already set for the FixedReader.Read method")
}
if len(mmRead.expectations) > 0 {
mmRead.mock.t.Fatalf("Some expectations are already set for the FixedReader.Read method")
}
mmRead.mock.funcRead = f
return mmRead.mock
}
// When sets expectation for the FixedReader.Read which will trigger the result defined by the following
// Then helper
func (mmRead *mFixedReaderMockRead) When(p []byte) *FixedReaderMockReadExpectation {
if mmRead.mock.funcRead != nil {
mmRead.mock.t.Fatalf("FixedReaderMock.Read mock is already set by Set")
}
expectation := &FixedReaderMockReadExpectation{
mock: mmRead.mock,
params: &FixedReaderMockReadParams{p},
}
mmRead.expectations = append(mmRead.expectations, expectation)
return expectation
}
// Then sets up FixedReader.Read return parameters for the expectation previously defined by the When method
func (e *FixedReaderMockReadExpectation) Then(n int, err error) *FixedReaderMock {
e.results = &FixedReaderMockReadResults{n, err}
return e.mock
}
// Read implements FixedReader
func (mmRead *FixedReaderMock) Read(p []byte) (n int, err error) {
mm_atomic.AddUint64(&mmRead.beforeReadCounter, 1)
defer mm_atomic.AddUint64(&mmRead.afterReadCounter, 1)
if mmRead.inspectFuncRead != nil {
mmRead.inspectFuncRead(p)
}
params := &FixedReaderMockReadParams{p}
// Record call args
mmRead.ReadMock.mutex.Lock()
mmRead.ReadMock.callArgs = append(mmRead.ReadMock.callArgs, params)
mmRead.ReadMock.mutex.Unlock()
for _, e := range mmRead.ReadMock.expectations {
if minimock.Equal(e.params, params) {
mm_atomic.AddUint64(&e.Counter, 1)
return e.results.n, e.results.err
}
}
if mmRead.ReadMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmRead.ReadMock.defaultExpectation.Counter, 1)
want := mmRead.ReadMock.defaultExpectation.params
got := FixedReaderMockReadParams{p}
if want != nil && !minimock.Equal(*want, got) {
mmRead.t.Errorf("FixedReaderMock.Read got unexpected parameters, want: %#v, got: %#v%s\n", *want, got, minimock.Diff(*want, got))
}
results := mmRead.ReadMock.defaultExpectation.results
if results == nil {
mmRead.t.Fatal("No results are set for the FixedReaderMock.Read")
}
return (*results).n, (*results).err
}
if mmRead.funcRead != nil {
return mmRead.funcRead(p)
}
mmRead.t.Fatalf("Unexpected call to FixedReaderMock.Read. %v", p)
return
}
// ReadAfterCounter returns a count of finished FixedReaderMock.Read invocations
func (mmRead *FixedReaderMock) ReadAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmRead.afterReadCounter)
}
// ReadBeforeCounter returns a count of FixedReaderMock.Read invocations
func (mmRead *FixedReaderMock) ReadBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmRead.beforeReadCounter)
}
// Calls returns a list of arguments used in each call to FixedReaderMock.Read.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmRead *mFixedReaderMockRead) Calls() []*FixedReaderMockReadParams {
mmRead.mutex.RLock()
argCopy := make([]*FixedReaderMockReadParams, len(mmRead.callArgs))
copy(argCopy, mmRead.callArgs)
mmRead.mutex.RUnlock()
return argCopy
}
// MinimockReadDone returns true if the count of the Read invocations corresponds
// the number of defined expectations
func (m *FixedReaderMock) MinimockReadDone() bool {
for _, e := range m.ReadMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
return false
}
}
// if default expectation was set then invocations count should be greater than zero
if m.ReadMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterReadCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcRead != nil && mm_atomic.LoadUint64(&m.afterReadCounter) < 1 {
return false
}
return true
}
// MinimockReadInspect logs each unmet expectation
func (m *FixedReaderMock) MinimockReadInspect() {
for _, e := range m.ReadMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Errorf("Expected call to FixedReaderMock.Read with params: %#v", *e.params)
}
}
// if default expectation was set then invocations count should be greater than zero
if m.ReadMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterReadCounter) < 1 {
if m.ReadMock.defaultExpectation.params == nil {
m.t.Error("Expected call to FixedReaderMock.Read")
} else {
m.t.Errorf("Expected call to FixedReaderMock.Read with params: %#v", *m.ReadMock.defaultExpectation.params)
}
}
// if func was set then invocations count should be greater than zero
if m.funcRead != nil && mm_atomic.LoadUint64(&m.afterReadCounter) < 1 {
m.t.Error("Expected call to FixedReaderMock.Read")
}
}
type mFixedReaderMockWriteTo struct {
mock *FixedReaderMock
defaultExpectation *FixedReaderMockWriteToExpectation
expectations []*FixedReaderMockWriteToExpectation
callArgs []*FixedReaderMockWriteToParams
mutex sync.RWMutex
}
// FixedReaderMockWriteToExpectation specifies expectation struct of the FixedReader.WriteTo
type FixedReaderMockWriteToExpectation struct {
mock *FixedReaderMock
params *FixedReaderMockWriteToParams
results *FixedReaderMockWriteToResults
Counter uint64
}
// FixedReaderMockWriteToParams contains parameters of the FixedReader.WriteTo
type FixedReaderMockWriteToParams struct {
w io.Writer
}
// FixedReaderMockWriteToResults contains results of the FixedReader.WriteTo
type FixedReaderMockWriteToResults struct {
n int64
err error
}
// Expect sets up expected params for FixedReader.WriteTo
func (mmWriteTo *mFixedReaderMockWriteTo) Expect(w io.Writer) *mFixedReaderMockWriteTo {
if mmWriteTo.mock.funcWriteTo != nil {
mmWriteTo.mock.t.Fatalf("FixedReaderMock.WriteTo mock is already set by Set")
}
if mmWriteTo.defaultExpectation == nil {
mmWriteTo.defaultExpectation = &FixedReaderMockWriteToExpectation{}
}
mmWriteTo.defaultExpectation.params = &FixedReaderMockWriteToParams{w}
for _, e := range mmWriteTo.expectations {
if minimock.Equal(e.params, mmWriteTo.defaultExpectation.params) {
mmWriteTo.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmWriteTo.defaultExpectation.params)
}
}
return mmWriteTo
}
// Inspect accepts an inspector function that has same arguments as the FixedReader.WriteTo
func (mmWriteTo *mFixedReaderMockWriteTo) Inspect(f func(w io.Writer)) *mFixedReaderMockWriteTo {
if mmWriteTo.mock.inspectFuncWriteTo != nil {
mmWriteTo.mock.t.Fatalf("Inspect function is already set for FixedReaderMock.WriteTo")
}
mmWriteTo.mock.inspectFuncWriteTo = f
return mmWriteTo
}
// Return sets up results that will be returned by FixedReader.WriteTo
func (mmWriteTo *mFixedReaderMockWriteTo) Return(n int64, err error) *FixedReaderMock {
if mmWriteTo.mock.funcWriteTo != nil {
mmWriteTo.mock.t.Fatalf("FixedReaderMock.WriteTo mock is already set by Set")
}
if mmWriteTo.defaultExpectation == nil {
mmWriteTo.defaultExpectation = &FixedReaderMockWriteToExpectation{mock: mmWriteTo.mock}
}
mmWriteTo.defaultExpectation.results = &FixedReaderMockWriteToResults{n, err}
return mmWriteTo.mock
}
//Set uses given function f to mock the FixedReader.WriteTo method
func (mmWriteTo *mFixedReaderMockWriteTo) Set(f func(w io.Writer) (n int64, err error)) *FixedReaderMock {
if mmWriteTo.defaultExpectation != nil {
mmWriteTo.mock.t.Fatalf("Default expectation is already set for the FixedReader.WriteTo method")
}
if len(mmWriteTo.expectations) > 0 {
mmWriteTo.mock.t.Fatalf("Some expectations are already set for the FixedReader.WriteTo method")
}
mmWriteTo.mock.funcWriteTo = f
return mmWriteTo.mock
}
// When sets expectation for the FixedReader.WriteTo which will trigger the result defined by the following
// Then helper
func (mmWriteTo *mFixedReaderMockWriteTo) When(w io.Writer) *FixedReaderMockWriteToExpectation {
if mmWriteTo.mock.funcWriteTo != nil {
mmWriteTo.mock.t.Fatalf("FixedReaderMock.WriteTo mock is already set by Set")
}
expectation := &FixedReaderMockWriteToExpectation{
mock: mmWriteTo.mock,
params: &FixedReaderMockWriteToParams{w},
}
mmWriteTo.expectations = append(mmWriteTo.expectations, expectation)
return expectation
}
// Then sets up FixedReader.WriteTo return parameters for the expectation previously defined by the When method
func (e *FixedReaderMockWriteToExpectation) Then(n int64, err error) *FixedReaderMock {
e.results = &FixedReaderMockWriteToResults{n, err}
return e.mock
}
// WriteTo implements FixedReader
func (mmWriteTo *FixedReaderMock) WriteTo(w io.Writer) (n int64, err error) {
mm_atomic.AddUint64(&mmWriteTo.beforeWriteToCounter, 1)
defer mm_atomic.AddUint64(&mmWriteTo.afterWriteToCounter, 1)
if mmWriteTo.inspectFuncWriteTo != nil {
mmWriteTo.inspectFuncWriteTo(w)
}
params := &FixedReaderMockWriteToParams{w}
// Record call args
mmWriteTo.WriteToMock.mutex.Lock()
mmWriteTo.WriteToMock.callArgs = append(mmWriteTo.WriteToMock.callArgs, params)
mmWriteTo.WriteToMock.mutex.Unlock()
for _, e := range mmWriteTo.WriteToMock.expectations {
if minimock.Equal(e.params, params) {
mm_atomic.AddUint64(&e.Counter, 1)
return e.results.n, e.results.err
}
}
if mmWriteTo.WriteToMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmWriteTo.WriteToMock.defaultExpectation.Counter, 1)
want := mmWriteTo.WriteToMock.defaultExpectation.params
got := FixedReaderMockWriteToParams{w}
if want != nil && !minimock.Equal(*want, got) {
mmWriteTo.t.Errorf("FixedReaderMock.WriteTo got unexpected parameters, want: %#v, got: %#v%s\n", *want, got, minimock.Diff(*want, got))
}
results := mmWriteTo.WriteToMock.defaultExpectation.results
if results == nil {
mmWriteTo.t.Fatal("No results are set for the FixedReaderMock.WriteTo")
}
return (*results).n, (*results).err
}
if mmWriteTo.funcWriteTo != nil {
return mmWriteTo.funcWriteTo(w)
}
mmWriteTo.t.Fatalf("Unexpected call to FixedReaderMock.WriteTo. %v", w)
return
}
// WriteToAfterCounter returns a count of finished FixedReaderMock.WriteTo invocations
func (mmWriteTo *FixedReaderMock) WriteToAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmWriteTo.afterWriteToCounter)
}
// WriteToBeforeCounter returns a count of FixedReaderMock.WriteTo invocations
func (mmWriteTo *FixedReaderMock) WriteToBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmWriteTo.beforeWriteToCounter)
}
// Calls returns a list of arguments used in each call to FixedReaderMock.WriteTo.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmWriteTo *mFixedReaderMockWriteTo) Calls() []*FixedReaderMockWriteToParams {
mmWriteTo.mutex.RLock()
argCopy := make([]*FixedReaderMockWriteToParams, len(mmWriteTo.callArgs))
copy(argCopy, mmWriteTo.callArgs)
mmWriteTo.mutex.RUnlock()
return argCopy
}
// MinimockWriteToDone returns true if the count of the WriteTo invocations corresponds
// the number of defined expectations
func (m *FixedReaderMock) MinimockWriteToDone() bool {
for _, e := range m.WriteToMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
return false
}
}
// if default expectation was set then invocations count should be greater than zero
if m.WriteToMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterWriteToCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcWriteTo != nil && mm_atomic.LoadUint64(&m.afterWriteToCounter) < 1 {
return false
}
return true
}
// MinimockWriteToInspect logs each unmet expectation
func (m *FixedReaderMock) MinimockWriteToInspect() {
for _, e := range m.WriteToMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Errorf("Expected call to FixedReaderMock.WriteTo with params: %#v", *e.params)
}
}
// if default expectation was set then invocations count should be greater than zero
if m.WriteToMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterWriteToCounter) < 1 {
if m.WriteToMock.defaultExpectation.params == nil {
m.t.Error("Expected call to FixedReaderMock.WriteTo")
} else {
m.t.Errorf("Expected call to FixedReaderMock.WriteTo with params: %#v", *m.WriteToMock.defaultExpectation.params)
}
}
// if func was set then invocations count should be greater than zero
if m.funcWriteTo != nil && mm_atomic.LoadUint64(&m.afterWriteToCounter) < 1 {
m.t.Error("Expected call to FixedReaderMock.WriteTo")
}
}
// MinimockFinish checks that all mocked methods have been called the expected number of times
func (m *FixedReaderMock) MinimockFinish() {
if !m.minimockDone() {
m.MinimockAsByteStringInspect()
m.MinimockAsBytesInspect()
m.MinimockFixedByteSizeInspect()
m.MinimockReadInspect()
m.MinimockWriteToInspect()
m.t.FailNow()
}
}
// MinimockWait waits for all mocked methods to be called the expected number of times
func (m *FixedReaderMock) MinimockWait(timeout mm_time.Duration) {
timeoutCh := mm_time.After(timeout)
for {
if m.minimockDone() {
return
}
select {
case <-timeoutCh:
m.MinimockFinish()
return
case <-mm_time.After(10 * mm_time.Millisecond):
}
}
}
func (m *FixedReaderMock) minimockDone() bool {
done := true
return done &&
m.MinimockAsByteStringDone() &&
m.MinimockAsBytesDone() &&
m.MinimockFixedByteSizeDone() &&
m.MinimockReadDone() &&
m.MinimockWriteToDone()
}