MCPcopy Create free account
hub / github.com/LyricTian/queue / TestListQueue

Function TestListQueue

list_queue_test.go:19–46  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17}
18
19func TestListQueue(t *testing.T) {
20 q := NewListQueue(2)
21 q.Run()
22
23 var data int64
24 q.Push(&testJob{
25 payload: 0,
26 callback: func(result int) {
27 atomic.AddInt64(&data, int64(result))
28 },
29 })
30 q.Push(&testJob{
31 payload: 0,
32 callback: func(result int) {
33 atomic.AddInt64(&data, int64(result))
34 },
35 })
36 q.Push(&testJob{
37 payload: 0,
38 callback: func(result int) {
39 atomic.AddInt64(&data, int64(result))
40 },
41 })
42 q.Terminate()
43 if data != 3 {
44 t.Error(data)
45 }
46}
47
48func ExampleListQueue() {
49 q := NewListQueue(10)

Callers

nothing calls this directly

Calls 5

RunMethod · 0.95
PushMethod · 0.95
TerminateMethod · 0.95
NewListQueueFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected