|
| 1 | +using AllocCheck |
| 2 | +using PoissonRandom |
| 3 | +using Random |
| 4 | + |
| 5 | +@testset "AllocCheck - Zero Allocations" begin |
| 6 | + @testset "count_rand" begin |
| 7 | + @check_allocs function test_count_rand(rng::TaskLocalRNG, λ::Float64) |
| 8 | + PoissonRandom.count_rand(rng, λ) |
| 9 | + end |
| 10 | + rng = Random.default_rng() |
| 11 | + @test test_count_rand(rng, 2.0) isa Int |
| 12 | + @test test_count_rand(rng, 5.0) isa Int |
| 13 | + end |
| 14 | + |
| 15 | + @testset "ad_rand" begin |
| 16 | + @check_allocs function test_ad_rand(rng::TaskLocalRNG, λ::Float64) |
| 17 | + PoissonRandom.ad_rand(rng, λ) |
| 18 | + end |
| 19 | + rng = Random.default_rng() |
| 20 | + @test test_ad_rand(rng, 10.0) isa Int |
| 21 | + @test test_ad_rand(rng, 50.0) isa Int |
| 22 | + end |
| 23 | + |
| 24 | + @testset "pois_rand" begin |
| 25 | + @check_allocs function test_pois_rand(rng::TaskLocalRNG, λ::Float64) |
| 26 | + pois_rand(rng, λ) |
| 27 | + end |
| 28 | + rng = Random.default_rng() |
| 29 | + @test test_pois_rand(rng, 2.0) isa Int |
| 30 | + @test test_pois_rand(rng, 10.0) isa Int |
| 31 | + end |
| 32 | + |
| 33 | + @testset "pois_rand with PassthroughRNG" begin |
| 34 | + @check_allocs function test_pois_rand_passthrough(rng::PassthroughRNG, λ::Float64) |
| 35 | + pois_rand(rng, λ) |
| 36 | + end |
| 37 | + passthrough = PassthroughRNG() |
| 38 | + @test test_pois_rand_passthrough(passthrough, 2.0) isa Int |
| 39 | + @test test_pois_rand_passthrough(passthrough, 10.0) isa Int |
| 40 | + end |
| 41 | + |
| 42 | + @testset "procf" begin |
| 43 | + @check_allocs function test_procf(λ::Float64, K::Int, s::Float64) |
| 44 | + PoissonRandom.procf(λ, K, s) |
| 45 | + end |
| 46 | + @test test_procf(10.0, 5, 3.162) isa NTuple{4, Float64} |
| 47 | + @test test_procf(10.0, 15, 3.162) isa NTuple{4, Float64} |
| 48 | + end |
| 49 | +end |
0 commit comments