From 163172b762c04fa62c2017c60654373af8006f77 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Tue, 28 Sep 2021 23:29:46 -0400 Subject: [PATCH] More tests for print --- .../src/test_dlcrq.jl | 13 +++++++++++ .../src/test_mpcrq.jl | 23 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/test/ConcurrentCollectionsTests/src/test_dlcrq.jl b/test/ConcurrentCollectionsTests/src/test_dlcrq.jl index e8a1f2d..e6e7b7d 100644 --- a/test/ConcurrentCollectionsTests/src/test_dlcrq.jl +++ b/test/ConcurrentCollectionsTests/src/test_dlcrq.jl @@ -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 diff --git a/test/ConcurrentCollectionsTests/src/test_mpcrq.jl b/test/ConcurrentCollectionsTests/src/test_mpcrq.jl index 727a917..c6c208e 100644 --- a/test/ConcurrentCollectionsTests/src/test_mpcrq.jl +++ b/test/ConcurrentCollectionsTests/src/test_mpcrq.jl @@ -3,7 +3,9 @@ module TestMPCRQ using Base.Experimental: @sync using ConcurrentCollections using ConcurrentCollections.Implementations: + DATA, IndirectMultiPolarityConcurrentRingQueueNode, + MPCRQSlot, MPCRQ_CLOSED, MPCRQ_ENQUEUED, Waiter, @@ -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 @@ -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