diff --git a/test/ConcurrentCollectionsTests/src/ConcurrentCollectionsTests.jl b/test/ConcurrentCollectionsTests/src/ConcurrentCollectionsTests.jl index 3d3c532..0df12c5 100644 --- a/test/ConcurrentCollectionsTests/src/ConcurrentCollectionsTests.jl +++ b/test/ConcurrentCollectionsTests/src/ConcurrentCollectionsTests.jl @@ -1,5 +1,6 @@ module ConcurrentCollectionsTests +include("utils.jl") include("test_bench_dict_histogram.jl") include("test_bench_smoke.jl") include("test_crq.jl") diff --git a/test/ConcurrentCollectionsTests/src/test_crq.jl b/test/ConcurrentCollectionsTests/src/test_crq.jl index 8eb52ae..edf64f0 100644 --- a/test/ConcurrentCollectionsTests/src/test_crq.jl +++ b/test/ConcurrentCollectionsTests/src/test_crq.jl @@ -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], @@ -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 @@ -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 diff --git a/test/ConcurrentCollectionsTests/src/test_dict.jl b/test/ConcurrentCollectionsTests/src/test_dict.jl index 6efc695..4b65182 100644 --- a/test/ConcurrentCollectionsTests/src/test_dict.jl +++ b/test/ConcurrentCollectionsTests/src/test_dict.jl @@ -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}() @@ -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 diff --git a/test/ConcurrentCollectionsTests/src/test_dlcrq.jl b/test/ConcurrentCollectionsTests/src/test_dlcrq.jl index e20d2c0..e8a1f2d 100644 --- a/test/ConcurrentCollectionsTests/src/test_dlcrq.jl +++ b/test/ConcurrentCollectionsTests/src/test_dlcrq.jl @@ -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], @@ -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 diff --git a/test/ConcurrentCollectionsTests/src/test_lcrq.jl b/test/ConcurrentCollectionsTests/src/test_lcrq.jl index b34ff5c..a31416a 100644 --- a/test/ConcurrentCollectionsTests/src/test_lcrq.jl +++ b/test/ConcurrentCollectionsTests/src/test_lcrq.jl @@ -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}() @@ -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 diff --git a/test/ConcurrentCollectionsTests/src/test_mpcrq.jl b/test/ConcurrentCollectionsTests/src/test_mpcrq.jl index 27adcc0..727a917 100644 --- a/test/ConcurrentCollectionsTests/src/test_mpcrq.jl +++ b/test/ConcurrentCollectionsTests/src/test_mpcrq.jl @@ -11,6 +11,7 @@ using ConcurrentCollections.Implementations: tryput! using ProgressLogging: @logprogress, @withprogress using Test +using ..Utils: ⊏ function test_close() crq = IndirectMultiPolarityConcurrentRingQueueNode{Int}(3) @@ -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 diff --git a/test/ConcurrentCollectionsTests/src/test_ssqueue.jl b/test/ConcurrentCollectionsTests/src/test_ssqueue.jl index b35e344..12bd294 100644 --- a/test/ConcurrentCollectionsTests/src/test_ssqueue.jl +++ b/test/ConcurrentCollectionsTests/src/test_ssqueue.jl @@ -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}() @@ -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) @@ -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 diff --git a/test/ConcurrentCollectionsTests/src/utils.jl b/test/ConcurrentCollectionsTests/src/utils.jl new file mode 100644 index 0000000..506760b --- /dev/null +++ b/test/ConcurrentCollectionsTests/src/utils.jl @@ -0,0 +1,3 @@ +module Utils +const ⊏ = occursin +end # module