(t *testing.T)
| 394 | } |
| 395 | |
| 396 | func TestUnDrainedIterBuffered(t *testing.T) { |
| 397 | slm := NewShardLockMaps() |
| 398 | |
| 399 | Total := 100 |
| 400 | for i := 0; i < Total; i++ { |
| 401 | slm.Set(strconv.Itoa(i), TestUser{strconv.Itoa(i)}) |
| 402 | } |
| 403 | counter := 0 |
| 404 | |
| 405 | // Iterate over elements. |
| 406 | ch := slm.IterBuffered() |
| 407 | for item := range ch { |
| 408 | val := item.Val |
| 409 | |
| 410 | if val == nil { |
| 411 | t.Error("Expecting an object.") |
| 412 | } |
| 413 | counter++ |
| 414 | if counter == 42 { |
| 415 | break |
| 416 | } |
| 417 | } |
| 418 | for i := Total; i < 2*Total; i++ { |
| 419 | slm.Set(strconv.Itoa(i), TestUser{strconv.Itoa(i)}) |
| 420 | } |
| 421 | for item := range ch { |
| 422 | val := item.Val |
| 423 | |
| 424 | if val == nil { |
| 425 | t.Error("Expecting an object.") |
| 426 | } |
| 427 | counter++ |
| 428 | } |
| 429 | |
| 430 | if counter != 100 { |
| 431 | t.Error("We should have been right where we stopped") |
| 432 | } |
| 433 | |
| 434 | counter = 0 |
| 435 | for item := range slm.IterBuffered() { |
| 436 | val := item.Val |
| 437 | |
| 438 | if val == nil { |
| 439 | t.Error("Expecting an object.") |
| 440 | } |
| 441 | counter++ |
| 442 | } |
| 443 | |
| 444 | if counter != 200 { |
| 445 | t.Error("We should have counted 200 elements.") |
| 446 | } |
| 447 | } |
| 448 | |
| 449 | func TestConcurrent(t *testing.T) { |
| 450 | slm := NewShardLockMaps() |
nothing calls this directly
no test coverage detected