Skip to content

Commit

Permalink
- add test
Browse files Browse the repository at this point in the history
  • Loading branch information
fbergmann committed Aug 27, 2024
1 parent 28076b5 commit c1f813c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/sbml/SBMLDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ class SBMLLevelVersionConverter;
#define StrictUnitsCheckON 0x80
#define StrictUnitsCheckOFF 0x7f
#define AllChecksON 0x7f
#define AllChecksONWithStrictUnits 0xff
/** @endcond */


Expand Down
46 changes: 46 additions & 0 deletions src/sbml/test/TestConsistencyChecks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,55 @@ START_TEST (test_strict_unit_consistency_checks)
fail_unless(d->getError(0)->getErrorId() == 10513);
fail_unless(d->getError(0)->getSeverity() == LIBSBML_SEV_ERROR);

d->getErrorLog()->clearLog();

// now once more as warning
errors = d->checkConsistencyWithStrictUnits(LIBSBML_OVERRIDE_WARNING);

fail_unless(errors == 1);
fail_unless(d->getError(0)->getErrorId() == 10513);
fail_unless(d->getError(0)->getSeverity() == LIBSBML_SEV_WARNING);



delete d;
}
END_TEST

START_TEST (test_check_consistency_settings)
{
SBMLReader reader;
SBMLDocument* d;
unsigned int errors;
std::string filename(TestDataDirectory);
filename += "l3v1-units.xml";


d = reader.readSBML(filename);

if (d == NULL)
{
fail("readSBML(\"l3v1-units.xml\") returned a NULL pointer.");
}

errors = d->checkConsistency();

fail_unless(errors == 0);

d->getErrorLog()->clearLog();

// now enable the strict units check
d->setConsistencyChecks(LIBSBML_CAT_STRICT_UNITS_CONSISTENCY, true);

errors = d->checkConsistency();

fail_unless(errors == 1);
fail_unless(d->getError(0)->getErrorId() == 10513);
fail_unless(d->getError(0)->getSeverity() == LIBSBML_SEV_WARNING);

delete d;
}
END_TEST

Suite *
create_suite_TestConsistencyChecks (void)
Expand All @@ -164,6 +209,7 @@ create_suite_TestConsistencyChecks (void)

tcase_add_test(tcase, test_consistency_checks);
tcase_add_test(tcase, test_strict_unit_consistency_checks);
tcase_add_test(tcase, test_check_consistency_settings);

suite_add_tcase(suite, tcase);

Expand Down
3 changes: 2 additions & 1 deletion src/sbml/validator/Validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,8 @@ Validator::validate (const SBMLDocument& d)

if (m != NULL)
{
if (this->getCategory() == LIBSBML_CAT_UNITS_CONSISTENCY)
if (this->getCategory() == LIBSBML_CAT_UNITS_CONSISTENCY ||
this->getCategory() == LIBSBML_CAT_STRICT_UNITS_CONSISTENCY)
{
/* create list of formula units for validation */
if (!m->isPopulatedListFormulaUnitsData())
Expand Down

0 comments on commit c1f813c

Please sign in to comment.