From d786086e22de3f5d1a42cb26706295451c2aafac Mon Sep 17 00:00:00 2001 From: Soeren Schoenbrod Date: Tue, 9 Feb 2021 13:58:05 +0100 Subject: [PATCH] Fix bug with resizing downconverted signal and add tests --- src/tracking_state.jl | 2 +- test/tracking_loop.jl | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/tracking_state.jl b/src/tracking_state.jl index daaa604..4419f21 100644 --- a/src/tracking_state.jl +++ b/src/tracking_state.jl @@ -46,7 +46,7 @@ end function DownconvertedSignalCPU(num_ants::NumAnts{N}) where N DownconvertedSignalCPU( - StructArray{Complex{Float32}}(undef, 0), + StructArray{Complex{Float32}}(undef, 0, N), StructArray{Complex{Float64}}(undef, 0, N) ) end diff --git a/test/tracking_loop.jl b/test/tracking_loop.jl index 1d5d40a..48be14a 100644 --- a/test/tracking_loop.jl +++ b/test/tracking_loop.jl @@ -8,6 +8,32 @@ @test @inferred(post_corr_filter(SVector(1.0 + 0.0im, 2.0 + 0.0im))) == 1.0 + 0.0im end +@testset "Resize downconverted signal for multiple ants" for type in (Float32, Float64) + downconverted_signal_temp = Tracking.DownconvertedSignalCPU(NumAnts(4)) + signal = StructArray(ones(Complex{type}, 2500, 4)) + downconverted_signal = Tracking.resize!(downconverted_signal_temp, 2500, signal) + if type == Float32 + @test size(downconverted_signal.downconverted_signal_f32) == (2500, 4) + @test size(downconverted_signal.downconverted_signal_f64) == (0, 4) + else + @test size(downconverted_signal.downconverted_signal_f32) == (0, 4) + @test size(downconverted_signal.downconverted_signal_f64) == (2500, 4) + end +end + +@testset "Resize downconverted signal for single ant" for type in (Float32, Float64) + downconverted_signal_temp = Tracking.DownconvertedSignalCPU(NumAnts(1)) + signal = StructArray(ones(Complex{type}, 2500)) + downconverted_signal = Tracking.resize!(downconverted_signal_temp, 2500, signal) + if type == Float32 + @test size(downconverted_signal.downconverted_signal_f32) == (2500,) + @test size(downconverted_signal.downconverted_signal_f64) == (0,) + else + @test size(downconverted_signal.downconverted_signal_f32) == (0,) + @test size(downconverted_signal.downconverted_signal_f64) == (2500,) + end +end + @testset "Integration time" begin gpsl1 = GPSL1() galileo_e1b = GalileoE1B()