Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions test/ConcurrentCollectionsTests/src/test_dlcrq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,23 @@ end

function test_print()
q = DualLinkedConcurrentRingQueue{Int}()
str = sprint(show, "text/plain", q)
@test "Dual LCRQ: " ⊏ str
@test "0 data item" ⊏ str

push!(q, 333)
str = sprint(show, "text/plain", q)
@test "Dual LCRQ: " ⊏ str
@test "1 data item" ⊏ str

popfirst!(q)
t = @task popfirst!(q)
yield(t)
str = sprint(show, "text/plain", q)
push!(q, 444)
wait(t)
@test "Dual LCRQ: " ⊏ str
@test "1 waiter" ⊏ str
end

end # module
23 changes: 23 additions & 0 deletions test/ConcurrentCollectionsTests/src/test_mpcrq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ module TestMPCRQ
using Base.Experimental: @sync
using ConcurrentCollections
using ConcurrentCollections.Implementations:
DATA,
IndirectMultiPolarityConcurrentRingQueueNode,
MPCRQSlot,
MPCRQ_CLOSED,
MPCRQ_ENQUEUED,
Waiter,
Expand All @@ -13,6 +15,16 @@ using ProgressLogging: @logprogress, @withprogress
using Test
using ..Utils: ⊏

function test_print_mpcrqslot()
slot = MPCRQSlot(; index = 111, safe = false, polarity = DATA, storage = UInt32(0xaaa))
str = sprint(show, "text/plain", slot)
@test "MPCRQSlot" ⊏ str
@test r"index *= *111" ⊏ str
@test r"safe *= *false" ⊏ str
@test r"polarity *=.*DATA" ⊏ str
@test r"storage *= *0x0+aaa" ⊏ str
end

function test_close()
crq = IndirectMultiPolarityConcurrentRingQueueNode{Int}(3)
@testset for i in 1:8
Expand Down Expand Up @@ -173,6 +185,17 @@ function test_print()
crq = IndirectMultiPolarityConcurrentRingQueueNode{Int}(3)
str = sprint(show, "text/plain", crq)
@test "MP-CRQ: " ⊏ str
@test "empty" ⊏ str

denqueue!(crq, 333)
str = sprint(show, "text/plain", crq)
@test "1 data item" ⊏ str

denqueue!(crq, Waiter{Int}()) # pop
w = Waiter{Int}()
denqueue!(crq, w)
str = sprint(show, "text/plain", crq)
@test "1 waiter" ⊏ str
end

end # module