Unverified Commit 1eb5975c authored by Miroslav Kratochvil's avatar Miroslav Kratochvil Committed by GitHub
Browse files

Merge pull request #104 from LCSB-BioCore/mk-converter-checks

check output of converters and throw julia errors in case something is wrong
parents e31a6971 b611ed82
...@@ -14,7 +14,7 @@ set_level_and_version(level, version) = ...@@ -14,7 +14,7 @@ set_level_and_version(level, version) =
doc, doc,
level, level,
version, version,
) ) == 0 && throw(ErrorException("Setting of level and version did not succeed"))
end end
""" """
...@@ -43,7 +43,8 @@ libsbml_convert( ...@@ -43,7 +43,8 @@ libsbml_convert(
opt, opt,
) )
end end
ccall(sbml(:SBMLDocument_convert), Cint, (VPtr, VPtr), doc, props) ccall(sbml(:SBMLDocument_convert), Cint, (VPtr, VPtr), doc, props) == 0 &&
throw(ErrorException("Conversion returned errors"))
end end
end end
......
...@@ -48,6 +48,14 @@ sbmlfiles = [ ...@@ -48,6 +48,14 @@ sbmlfiles = [
104, 104,
52, 52,
), ),
# this contains l3v1-incompatible contents
(
joinpath(@__DIR__, "data", "sbml01289.xml"),
"https://raw.githubusercontent.com/sbmlteam/sbml-test-suite/master/cases/semantic/01289/01289-sbml-l3v2.xml",
"35ffa072052970b92fa358ee0f5750394ad74958e889cb85c98ed238642de4d0",
0,
0,
),
] ]
@testset "Loading of models from various sources" begin @testset "Loading of models from various sources" begin
...@@ -125,3 +133,13 @@ end ...@@ -125,3 +133,13 @@ end
@variables S29 S29b @variables S29 S29b
@test isequal(convert(Num, m.reactions["J29"].kinetic_math), 2.0 * S29 * S29b) @test isequal(convert(Num, m.reactions["J29"].kinetic_math), 2.0 * S29 * S29b)
end end
@testset "converters fail gracefully" begin
@test_throws ErrorException readSBML(
joinpath(@__DIR__, "data", "sbml01289.xml"),
doc -> begin
set_level_and_version(3, 1)(doc)
convert_simplify_math(doc)
end,
)
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment