(t *testing.T)
| 22 | } |
| 23 | |
| 24 | func TestByteSemaphoreCapChangeUp(t *testing.T) { |
| 25 | t.Parallel() |
| 26 | |
| 27 | // Waiting takes should unblock when the capacity increases |
| 28 | |
| 29 | s := New(100) |
| 30 | |
| 31 | s.Take(75) |
| 32 | if s.available != 25 { |
| 33 | t.Error("bad state after take") |
| 34 | } |
| 35 | |
| 36 | gotit := make(chan struct{}) |
| 37 | go func() { |
| 38 | s.Take(75) |
| 39 | close(gotit) |
| 40 | }() |
| 41 | |
| 42 | s.SetCapacity(155) |
| 43 | <-gotit |
| 44 | if s.available != 5 { |
| 45 | t.Error("bad state after both takes") |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | func TestByteSemaphoreCapChangeDown1(t *testing.T) { |
| 50 | t.Parallel() |
nothing calls this directly
no test coverage detected