MCPcopy
hub / github.com/syncthing/syncthing / TestByteSemaphoreCapChangeDown1

Function TestByteSemaphoreCapChangeDown1

lib/semaphore/semaphore_test.go:49–70  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

47}
48
49func TestByteSemaphoreCapChangeDown1(t *testing.T) {
50 t.Parallel()
51
52 // Things should make sense when capacity is adjusted down
53
54 s := New(100)
55
56 s.Take(75)
57 if s.available != 25 {
58 t.Error("bad state after take")
59 }
60
61 s.SetCapacity(90)
62 if s.available != 15 {
63 t.Error("bad state after adjust")
64 }
65
66 s.Give(75)
67 if s.available != 90 {
68 t.Error("bad state after give")
69 }
70}
71
72func TestByteSemaphoreCapChangeDown2(t *testing.T) {
73 t.Parallel()

Callers

nothing calls this directly

Calls 5

SetCapacityMethod · 0.80
NewFunction · 0.70
ErrorMethod · 0.65
TakeMethod · 0.45
GiveMethod · 0.45

Tested by

no test coverage detected