MCPcopy Create free account
hub / github.com/allegro/bigcache / TestResetFullQueue

Function TestResetFullQueue

queue/bytes_queue_test.go:74–98  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

72}
73
74func TestResetFullQueue(t *testing.T) {
75 t.Parallel()
76
77 // given
78 queue := NewBytesQueue(10, 20, false)
79
80 // when
81 queue.Push(blob('a', 3))
82 queue.Push(blob('b', 4))
83
84 // when
85 assertEqual(t, blob('a', 3), pop(queue)) // space freed at the beginning
86 _, err := queue.Push(blob('a', 3)) // will set q.full to true
87
88 // then
89 assertEqual(t, err, nil)
90
91 // when
92 queue.Reset()
93 queue.Push(blob('c', 8)) // should not trigger a re-allocation
94
95 // then
96 assertEqual(t, blob('c', 8), pop(queue))
97 assertEqual(t, queue.Capacity(), 10)
98}
99
100func TestReset(t *testing.T) {
101 t.Parallel()

Callers

nothing calls this directly

Calls 7

PushMethod · 0.95
ResetMethod · 0.95
CapacityMethod · 0.95
NewBytesQueueFunction · 0.85
popFunction · 0.85
blobFunction · 0.70
assertEqualFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…