Skip to content

Commit cd457e8

Browse files
committed
Add caching recoplan tests
1 parent 5453509 commit cd457e8

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

test/caching.jl

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
@testset "Caching" begin
2-
mutable struct CacheableParameter <: AbstractImageReconstructionParameters
2+
Base.@kwdef mutable struct CacheableParameter <: AbstractImageReconstructionParameters
33
factor::Int64
44
cache_misses::Ref{Int64}
55
end
6-
mutable struct PureCacheableParameter <: AbstractImageReconstructionParameters
6+
Base.@kwdef mutable struct PureCacheableParameter <: AbstractImageReconstructionParameters
77
factor::Int64
88
cache_misses::Ref{Int64}
99
end
@@ -170,7 +170,28 @@
170170
end
171171

172172
@testset "RecoPlan" begin
173-
173+
cache_misses = Ref(0)
174+
cached_parameter = CacheableParameter(3, cache_misses)
175+
cache = ProcessResultCache(; param = cached_parameter, maxsize = 1)
176+
177+
plan = toPlan(cache)
178+
setAll!(plan, :maxsize, 3)
179+
@test plan.cache.maxsize == 3
180+
181+
clear!(plan.param)
182+
io = IOBuffer()
183+
toTOML(io, plan)
184+
seekstart(io)
185+
planCopy = loadPlan(io, [Main, AbstractImageReconstruction])
186+
187+
setAll!(planCopy, :factor, 3)
188+
setAll!(planCopy, :cache_misses, Ref(0))
189+
copy1 = build(planCopy)
190+
copy2 = build(planCopy)
191+
@test copy1.cache == copy2.cache
192+
resize!(copy1, 42)
193+
194+
@test copy2.cache.maxsize == 42
174195
end
175196

176197
end

0 commit comments

Comments
 (0)