Skip to content

Commit

Permalink
Improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Adomas Baliuka authored and Adomas Baliuka committed May 23, 2023
1 parent 649899e commit 8833980
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/cscmat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,17 @@ function load_matrix_from_qc_cscmat_file(file_path::AbstractString; expansion_fa
if isnothing(expansion_factor)
header = ""
next_line = ""

open(file_path, "r") do f
while true
header *= (next_line * "\n")
next_line = readline(f)

(length(next_line) > 0 && next_line[1] == '#') || break
try
open(file_path, "r") do f
while true
header *= (next_line * "\n")
next_line = readline(f)

(length(next_line) > 0 && next_line[1] == '#') || break
end
end
catch e
throw(InconsistentBINCSCError("Failed to parse header of file '$file_path'. Not a valid qc-cscmat file? Reason:\n$e"))
end

m = match(r"Quasi cyclic exponents for a binary LDPC matrix with expansion factor ([0-9]*)\.", header)
Expand All @@ -226,7 +229,12 @@ function load_matrix_from_qc_cscmat_file(file_path::AbstractString; expansion_fa
end
end

Hqc = load_cscmat(file_path)
local Hqc
try
Hqc = load_cscmat(file_path)
catch e
throw(InconsistentBINCSCError("Failed to parse contents of file '$file_path'. Not a valid qc-cscmat file? Reason:\n$e"))
end

H = Hqc_to_pcm(Hqc, expansion_factor)

Expand Down
2 changes: 2 additions & 0 deletions test/test_cscmat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ end
end
end

# test failures
@test_throws LDPCStorage.InconsistentBINCSCError load_matrix_from_qc_cscmat_file("$(pkgdir(LDPCStorage))/test/files/test_H.bincsc.json"; expansion_factor=32)
end


Expand Down

0 comments on commit 8833980

Please sign in to comment.