From ac6bca346c72ba6296e4311e4fa9eae2d6f1232b Mon Sep 17 00:00:00 2001 From: Sarah Keating Date: Sat, 3 Aug 2024 14:51:33 +0100 Subject: [PATCH] put in some testing for distribution units --- .../test/TestDistribConsistencyValidator.cpp | 27 ++++- .../distrib/validator/test/TestFile.cpp | 9 +- .../unit-constraints/1510523-fail-01-01.xml | 102 ++++++++++++++++++ ...{spt_random.xml => 1510523-pass-00-01.xml} | 0 4 files changed, 133 insertions(+), 5 deletions(-) create mode 100644 src/sbml/packages/distrib/validator/test/test-data/unit-constraints/1510523-fail-01-01.xml rename src/sbml/packages/distrib/validator/test/test-data/unit-constraints/{spt_random.xml => 1510523-pass-00-01.xml} (100%) diff --git a/src/sbml/packages/distrib/validator/test/TestDistribConsistencyValidator.cpp b/src/sbml/packages/distrib/validator/test/TestDistribConsistencyValidator.cpp index 1a5ac6f178..9318dc4289 100644 --- a/src/sbml/packages/distrib/validator/test/TestDistribConsistencyValidator.cpp +++ b/src/sbml/packages/distrib/validator/test/TestDistribConsistencyValidator.cpp @@ -44,6 +44,7 @@ #include #include +#include #ifdef LIBSBML_USE_VLD #include @@ -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); @@ -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; } diff --git a/src/sbml/packages/distrib/validator/test/TestFile.cpp b/src/sbml/packages/distrib/validator/test/TestFile.cpp index ae92c67cc3..bae51daf30 100644 --- a/src/sbml/packages/distrib/validator/test/TestFile.cpp +++ b/src/sbml/packages/distrib/validator/test/TestFile.cpp @@ -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; } diff --git a/src/sbml/packages/distrib/validator/test/test-data/unit-constraints/1510523-fail-01-01.xml b/src/sbml/packages/distrib/validator/test/test-data/unit-constraints/1510523-fail-01-01.xml new file mode 100644 index 0000000000..253d90f026 --- /dev/null +++ b/src/sbml/packages/distrib/validator/test/test-data/unit-constraints/1510523-fail-01-01.xml @@ -0,0 +1,102 @@ + + + + +

Created with https://github.com/matthiaskoenig/sbmlutils. + + DOI

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + uniform + 0 + 1 + + + + + +
diff --git a/src/sbml/packages/distrib/validator/test/test-data/unit-constraints/spt_random.xml b/src/sbml/packages/distrib/validator/test/test-data/unit-constraints/1510523-pass-00-01.xml similarity index 100% rename from src/sbml/packages/distrib/validator/test/test-data/unit-constraints/spt_random.xml rename to src/sbml/packages/distrib/validator/test/test-data/unit-constraints/1510523-pass-00-01.xml