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
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module ConcurrentCollectionsTests

include("utils.jl")
include("test_bench_dict_histogram.jl")
include("test_bench_smoke.jl")
include("test_crq.jl")
Expand Down
16 changes: 16 additions & 0 deletions test/ConcurrentCollectionsTests/src/test_crq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ using ConcurrentCollections.Implementations:
CRQSlot, IndirectConcurrentRingQueueNode, trypush!, isclosed
using ProgressLogging: @logprogress, @withprogress
using Test
using ..Utils: ⊏

function test_CRQSlot()
for index in [111, 222],
Expand All @@ -16,6 +17,15 @@ function test_CRQSlot()
end
end

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

function unfair_sleep(seconds::Real)
t0 = time_ns()
ns = seconds * 1e9
Expand Down Expand Up @@ -163,4 +173,10 @@ function check_concurrent_push_pop()
@test allreceived == 1:nitems
end

function test_print()
crq = IndirectConcurrentRingQueueNode{Int16}(32)
str = sprint(show, "text/plain", crq)
@test "CRQ: " ⊏ str
end

end # module
9 changes: 9 additions & 0 deletions test/ConcurrentCollectionsTests/src/test_dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ using ConcurrentCollections
using ConcurrentCollections.Implementations: clusters, migrate!
using SyncBarriers: Barrier, cycle!
using Test
using ..Utils: ⊏

function test_expand_and_shrink(n = 17)
d = ConcurrentDict{Int,Int}()
Expand Down Expand Up @@ -259,4 +260,12 @@ function test_phased_push_pop(; nkeys = 16, phases = 2^10, kwargs...)
@test actual == desired
end

function test_print()
d = ConcurrentDict(111 => 222, 333 => 444)
str = sprint(show, "text/plain", d)
@test "ConcurrentDict" ⊏ str
@test "111 => 222" ⊏ str
@test "333 => 444" ⊏ str
end

end # module
9 changes: 9 additions & 0 deletions test/ConcurrentCollectionsTests/src/test_dlcrq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ using ConcurrentCollections.Implementations:
MPCRQSlot, DATA, ANTIDATA, denqueue!, MPCRQ_ENQUEUED
using ProgressLogging: @logprogress, @withprogress
using Test
using ..Utils: ⊏

function test_MPCRQSlot()
for index in [111, 222],
Expand Down Expand Up @@ -169,4 +170,12 @@ function check_concurrent_push_pop!(q; nitems = 2^20)
@test allreceived == 1:nitems
end

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

end # module
9 changes: 9 additions & 0 deletions test/ConcurrentCollectionsTests/src/test_lcrq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ using Base.Experimental: @sync
using ConcurrentCollections
using ProgressLogging: @logprogress, @withprogress
using Test
using ..Utils: ⊏

function test_push_pop_once_int()
q = LinkedConcurrentRingQueue{Int}()
Expand Down Expand Up @@ -104,4 +105,12 @@ function check_concurrent_push_pop()
@test allreceived == 1:nitems
end

function test_print()
q = LinkedConcurrentRingQueue{Int}()
push!(q, 333)
str = sprint(show, "text/plain", q)
@test "LCRQ: " ⊏ str
@test "1 item" ⊏ str
end

end # module
7 changes: 7 additions & 0 deletions test/ConcurrentCollectionsTests/src/test_mpcrq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ using ConcurrentCollections.Implementations:
tryput!
using ProgressLogging: @logprogress, @withprogress
using Test
using ..Utils: ⊏

function test_close()
crq = IndirectMultiPolarityConcurrentRingQueueNode{Int}(3)
Expand Down Expand Up @@ -168,4 +169,10 @@ function check_concurrent_push_pop()
@test allreceived == 1:nitems
end

function test_print()
crq = IndirectMultiPolarityConcurrentRingQueueNode{Int}(3)
str = sprint(show, "text/plain", crq)
@test "MP-CRQ: " ⊏ str
end

end # module
19 changes: 18 additions & 1 deletion test/ConcurrentCollectionsTests/src/test_ssqueue.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
module TestSSQueue

using ConcurrentCollections
using ConcurrentCollections.Implementations: NodeIterator, SSQNode, check_invariance
using ConcurrentCollections.Implementations: NodeIterator, SSQNode, check_invariance, ==′
using ProgressLogging: @logprogress, @withprogress
using Test
using ..TestDLCRQ: check_concurrent_push_pop!
using ..Utils: ⊏

function test_push_pop_once_int()
q = DualLinkedQueue{Int}()
Expand Down Expand Up @@ -45,6 +46,14 @@ function test_concurrent_push_pop(ntrials = 100)
end
end

function test_iter()
q = DualLinkedQueue{Int}()
@test eltype(q) === Int
push!(q, 111)
push!(q, 222)
@test collect(q) ==′ [111, 222]
end

function test_nodeiterator()
q = DualLinkedQueue{Int}()
push!(q, 111)
Expand All @@ -57,4 +66,12 @@ function test_nodeiterator()
@test check_invariance(q)
end

function test_print()
q = DualLinkedQueue{Int}()
push!(q, 111)
push!(q, 222)
str = sprint(show, "text/plain", q)
@test "DualLinkedQueue" ⊏ str
end

end # module
3 changes: 3 additions & 0 deletions test/ConcurrentCollectionsTests/src/utils.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Utils
const ⊏ = occursin
end # module