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