Add more tests.
This commit is contained in:
parent
522530ee9a
commit
428c2b948c
|
@ -366,6 +366,44 @@ suite "Asynchronous sync primitives test suite":
|
|||
(waitFor q.peekFirst()) == 1
|
||||
(waitFor q.peekLast()) == 2
|
||||
|
||||
test "AsyncQueue() peek before pop test":
|
||||
let q = newAsyncQueue[int]()
|
||||
q.putNoWait(1)
|
||||
|
||||
let
|
||||
a = q.peekFirst()
|
||||
b = q.popFirst()
|
||||
|
||||
check:
|
||||
a.completed() == true
|
||||
b.completed() == true
|
||||
a.read() == 1
|
||||
b.read() == 1
|
||||
q.len() == 0
|
||||
|
||||
test "AsyncQueue() peek after pop test":
|
||||
let q = newAsyncQueue[int]()
|
||||
q.putNoWait(1)
|
||||
|
||||
let
|
||||
a = q.popFirst()
|
||||
b = q.peekFirst()
|
||||
|
||||
check:
|
||||
a.completed() == true
|
||||
b.completed() == false
|
||||
a.read() == 1
|
||||
q.len() == 0
|
||||
|
||||
q.putNoWait(2)
|
||||
poll()
|
||||
|
||||
check:
|
||||
a.completed() == true
|
||||
b.completed() == true
|
||||
b.read() == 2
|
||||
q.len() == 1
|
||||
|
||||
test "AsyncEventQueue() behavior test":
|
||||
let eventQueue = newAsyncEventQueue[int]()
|
||||
let key = eventQueue.register()
|
||||
|
|
Loading…
Reference in New Issue