diff --git a/test/runtests.jl b/test/runtests.jl index 41f7cbc..0261b4b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -16,6 +16,9 @@ include("test_bitMapping.jl"); include("test_bitDemapping.jl"); include("test_hardConstellation.jl"); +# NRZI Mapping +include("test_NRZI.jl"); + # Symbol demapper include("test_symbolDemapper.jl"); diff --git a/test/test_nrzi.jl b/test/test_nrzi.jl new file mode 100644 index 0000000..4c39872 --- /dev/null +++ b/test/test_nrzi.jl @@ -0,0 +1,29 @@ +# ---------------------------------------------------- +# --- Import modules +# ---------------------------------------------------- +using DigitalComm +using Test +# ---------------------------------------------------- +# --- Tests +# ---------------------------------------------------- +# Note --> The mapping system is described in bitMapping.jl +println("Tests for symbol mapper with NRZI sequences"); + +@testset "NRZI" begin + # Create a bit squence (already tested) + nbBits = 2 * 2048; + bitSeq = genBitSequence(nbBits); + # Pass trough the function + buff = zeros(Complex{Float64},nbBits) + # Call + encodeNRZI!(buff,bitSeq); + buff2 = encodeNRZI(bitSeq); + @test all( buff .== buff2) + # Ensure Tx // Rx is Ok + @test all(bitSeq .== decodeNRZI(encodeNRZI(bitSeq))) + @test all(bitSeq .== decodeNRZI(encodeNRZI(bitSeq,:high),:high)) + # Some manual check for both transitions + buff = [0x01;0x00;0x00;0x01;0x00;0x00;0x00;0x01 ]; + @test all( encodeNRZI(buff,:low) .== [0;1;0;0;1;0;1;1]) # Transitions on 0 + @test all( encodeNRZI(buff,:high) .== [1;1;1;0;0;0;0;1]) # Transitions on 1 +end