Skip to content

Commit

Permalink
put in some testing for distribution units
Browse files Browse the repository at this point in the history
  • Loading branch information
skeating committed Aug 3, 2024
1 parent 5b27f56 commit ac6bca3
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

#include <sbml/packages/distrib/validator/DistribConsistencyValidator.h>
#include <sbml/packages/distrib/validator/DistribIdentifierConsistencyValidator.h>
#include <sbml/validator/UnitConsistencyValidator.h>

#ifdef LIBSBML_USE_VLD
#include <vld.h>
Expand Down Expand Up @@ -85,6 +86,21 @@ runIdTest (const TestFile& file)
TestValidator tester(validator);


validator.init();

return tester.test(file);
}
/**
* @return true if the Validator behaved as expected when validating
* TestFile, false otherwise.
*/
bool
runUnitTest (const TestFile& file)
{
UnitConsistencyValidator validator;
TestValidator tester(validator);


validator.init();

return tester.test(file);
Expand Down Expand Up @@ -164,9 +180,14 @@ main (int argc, char* argv[])
failed += runTests( "Testing General XML Consistency Constraints (20000 - 29999)",
testThisDataDir, 0, 0, runMainTest, library);

testThisDataDir = testDataDir + "/" + "identifier-constraints";
failed += runTests( "Testing Id Consistency Constraints (10300 - 10399)",
testThisDataDir, 0, 0, runIdTest, library);
// commented out as we don't actually have any of these tests
//testThisDataDir = testDataDir + "/" + "identifier-constraints";
//failed += runTests( "Testing Id Consistency Constraints (10300 - 10399)",
// testThisDataDir, 0, 0, runIdTest, library);

testThisDataDir = testDataDir + "/" + "unit-constraints";
failed += runTests("Testing Unit Consistency Constraints (10500 - 10599)",
testThisDataDir, 0, 0, runUnitTest, library);

return failed;
}
Expand Down
9 changes: 7 additions & 2 deletions src/sbml/packages/distrib/validator/test/TestFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,13 @@ TestFile::getFullname () const

unsigned int
TestFile::getConstraintId () const
{
return atol( mFilename.substr(0, 7).c_str() );
{
unsigned int constraint = atol( mFilename.substr(0, 7).c_str() );
if (constraint > 1510500 && constraint < 1510599)
{
constraint = constraint - 1500000;
}
return constraint;
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level3/version2/core" xmlns:comp="http://www.sbml.org/sbml/level3/version1/comp/version1" xmlns:distrib="http://www.sbml.org/sbml/level3/version1/distrib/version1" level="3" version="2" comp:required="true" distrib:required="true">
<notes>
<body xmlns="http://www.w3.org/1999/xhtml">
<p>Created with <a href="https://github.com/matthiaskoenig/sbmlutils">https://github.com/matthiaskoenig/sbmlutils</a>.
<a href="https://doi.org/10.5281/zenodo.5525390">
<img src="https://zenodo.org/badge/DOI/10.5281/zenodo.5525390.svg" alt="DOI"/></a></p>
</body>
</notes>
<model id="spt_random" name="Model for testing uniform units" substanceUnits="mmole" timeUnits="min" volumeUnits="litre" areaUnits="m2" lengthUnits="metre" extentUnits="mmole">
<listOfUnitDefinitions>
<unitDefinition id="g_per_mole" name="g/mole">
<listOfUnits>
<unit kind="gram" exponent="1" scale="0" multiplier="1"/>
<unit kind="mole" exponent="-1" scale="0" multiplier="1"/>
</listOfUnits>
</unitDefinition>
<unitDefinition id="l_per_min" name="l/min">
<listOfUnits>
<unit kind="litre" exponent="1" scale="0" multiplier="1"/>
<unit kind="second" exponent="-1" scale="0" multiplier="60"/>
</listOfUnits>
</unitDefinition>
<unitDefinition id="m2" name="meter^2">
<listOfUnits>
<unit kind="metre" exponent="2" scale="0" multiplier="1"/>
</listOfUnits>
</unitDefinition>
<unitDefinition id="mM" name="mmole/liter">
<listOfUnits>
<unit kind="mole" exponent="1" scale="0" multiplier="0.001"/>
<unit kind="litre" exponent="-1" scale="0" multiplier="1"/>
</listOfUnits>
</unitDefinition>
<unitDefinition id="mg" name="mg">
<listOfUnits>
<unit kind="gram" exponent="1" scale="0" multiplier="0.001"/>
</listOfUnits>
</unitDefinition>
<unitDefinition id="mg_per_s_l" name="mg/s/l">
<listOfUnits>
<unit kind="gram" exponent="1" scale="0" multiplier="0.001"/>
<unit kind="second" exponent="-1" scale="0" multiplier="1"/>
<unit kind="litre" exponent="-1" scale="0" multiplier="1"/>
</listOfUnits>
</unitDefinition>
<unitDefinition id="min" name="min">
<listOfUnits>
<unit kind="second" exponent="1" scale="0" multiplier="60"/>
</listOfUnits>
</unitDefinition>
<unitDefinition id="min_per_hr" name="min/hour">
<listOfUnits>
<unit kind="second" exponent="1" scale="0" multiplier="60"/>
<unit kind="second" exponent="-1" scale="0" multiplier="3600"/>
</listOfUnits>
</unitDefinition>
<unitDefinition id="mmole" name="mmole">
<listOfUnits>
<unit kind="mole" exponent="1" scale="0" multiplier="0.001"/>
</listOfUnits>
</unitDefinition>
<unitDefinition id="mmole_per_min" name="mmole/min">
<listOfUnits>
<unit kind="mole" exponent="1" scale="0" multiplier="0.001"/>
<unit kind="second" exponent="-1" scale="0" multiplier="60"/>
</listOfUnits>
</unitDefinition>
<unitDefinition id="mmole_per_min_l" name="mmole/min/l">
<listOfUnits>
<unit kind="mole" exponent="1" scale="0" multiplier="0.001"/>
<unit kind="second" exponent="-1" scale="0" multiplier="60"/>
<unit kind="litre" exponent="-1" scale="0" multiplier="1"/>
</listOfUnits>
</unitDefinition>
<unitDefinition id="per_min" name="1/min">
<listOfUnits>
<unit kind="second" exponent="-1" scale="0" multiplier="60"/>
</listOfUnits>
</unitDefinition>
<unitDefinition id="per_mmole" name="1/mmole">
<listOfUnits>
<unit kind="mole" exponent="-1" scale="0" multiplier="0.001"/>
</listOfUnits>
</unitDefinition>
</listOfUnitDefinitions>
<listOfParameters>
<parameter id="protein_random" value="0.5" units="second" constant="true"/>
</listOfParameters>
<listOfInitialAssignments>
<initialAssignment symbol="protein_random">
<math xmlns="http://www.w3.org/1998/Math/MathML" xmlns:sbml="http://www.sbml.org/sbml/level3/version2/core">
<apply>
<csymbol encoding="text" definitionURL="http://www.sbml.org/sbml/symbols/distrib/uniform"> uniform </csymbol>
<cn sbml:units="dimensionless" type="integer"> 0 </cn>
<cn sbml:units="dimensionless" type="integer"> 1 </cn>
</apply>
</math>
</initialAssignment>
</listOfInitialAssignments>
</model>
</sbml>

0 comments on commit ac6bca3

Please sign in to comment.