Skip to content

Commit

Permalink
Adding test file for NRZI
Browse files Browse the repository at this point in the history
  • Loading branch information
RGerzaguet committed Mar 11, 2024
1 parent 83800f4 commit 2127952
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
29 changes: 29 additions & 0 deletions test/test_nrzi.jl
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2127952

Please sign in to comment.