(t *testing.T)
| 31 | } |
| 32 | |
| 33 | func TestSharedBufferMultiple(t *testing.T) { |
| 34 | buf := NewSharedBuffer(3) |
| 35 | |
| 36 | ch1 := buf.NewChannel() |
| 37 | ch2 := buf.NewChannel() |
| 38 | |
| 39 | ch1.In() <- (*int)(nil) |
| 40 | ch1.In() <- (*int)(nil) |
| 41 | ch1.In() <- (*int)(nil) |
| 42 | |
| 43 | select { |
| 44 | case ch2.In() <- (*int)(nil): |
| 45 | t.Error("Wrote to full shared-buffer") |
| 46 | case <-ch2.Out(): |
| 47 | t.Error("Read from empty channel") |
| 48 | default: |
| 49 | } |
| 50 | |
| 51 | <-ch1.Out() |
| 52 | |
| 53 | for i := 0; i < 10; i++ { |
| 54 | ch2.In() <- (*int)(nil) |
| 55 | |
| 56 | select { |
| 57 | case ch1.In() <- (*int)(nil): |
| 58 | t.Error("Wrote to full shared-buffer") |
| 59 | case ch2.In() <- (*int)(nil): |
| 60 | t.Error("Wrote to full shared-buffer") |
| 61 | default: |
| 62 | } |
| 63 | |
| 64 | <-ch2.Out() |
| 65 | } |
| 66 | |
| 67 | <-ch1.Out() |
| 68 | <-ch1.Out() |
| 69 | |
| 70 | ch1.Close() |
| 71 | ch2.Close() |
| 72 | buf.Close() |
| 73 | } |
| 74 | |
| 75 | func TestSharedBufferConcurrent(t *testing.T) { |
| 76 | const threads = 10 |
nothing calls this directly
no test coverage detected
searching dependent graphs…