END_TEST START_TEST (test_comp_sbmldocument) { SBMLNamespaces sbmlns(3,1,"comp",1); SBMLDocument doc(&sbmlns); CompSBMLDocumentPlugin* docplugin = static_cast<CompSBMLDocumentPlugin*>(doc.getPlugin("comp")); doc.setPackageRequired("comp", true); fail_unless(docplugin->getRequired() == true); fail_unless(docplugin->getNumModelDefinitions()==0); ModelDefinition* moddef = docplugin->createModelDefinition(); moddef->setId("moddef1"); fail_unless(docplugin->getNumModelDefinitions()==1); fail_unless(docplugin->addModelDefinition(NULL)==LIBSBML_INVALID_OBJECT); ModelDefinition moddef2(3, 1); moddef2.setId("moddef2"); fail_unless(docplugin->addModelDefinition(&moddef2)==LIBSBML_OPERATION_SUCCESS); ModelDefinition* moddefref = docplugin->getModelDefinition("moddef2"); fail_unless(moddefref->getId()=="moddef2"); moddefref = docplugin->getModelDefinition(0); fail_unless(moddefref->getId()=="moddef1"); moddef->setId("ID1"); fail_unless(moddefref->getId()=="ID1"); fail_unless(docplugin->removeModelDefinition(3)==NULL); fail_unless(docplugin->removeModelDefinition(0)==moddef); fail_unless(docplugin->getModelDefinition("moddef1")==NULL); fail_unless(docplugin->getNumExternalModelDefinitions()==0); ExternalModelDefinition* exmoddef = docplugin->createExternalModelDefinition(); exmoddef->setId("exmoddef1"); fail_unless(docplugin->getNumExternalModelDefinitions()==1); fail_unless(docplugin->addExternalModelDefinition(NULL)==LIBSBML_INVALID_OBJECT); ExternalModelDefinition exmoddef2(3, 1); exmoddef2.setId("exmoddef2"); fail_unless(docplugin->addExternalModelDefinition(&exmoddef2)==LIBSBML_INVALID_OBJECT); exmoddef2.setSource("where/the/file/is.xml"); fail_unless(docplugin->addExternalModelDefinition(&exmoddef2)==LIBSBML_OPERATION_SUCCESS); ExternalModelDefinition* exmoddefref = docplugin->getExternalModelDefinition("exmoddef2"); fail_unless(exmoddefref->getId()=="exmoddef2"); exmoddefref = docplugin->getExternalModelDefinition(0); fail_unless(exmoddefref->getId()=="exmoddef1"); exmoddef->setModelRef("ID1"); fail_unless(exmoddefref->getModelRef()=="ID1"); fail_unless(docplugin->removeExternalModelDefinition(3)==NULL); fail_unless(docplugin->removeExternalModelDefinition(0)==exmoddef); fail_unless(docplugin->getExternalModelDefinition("exmoddef1")==NULL); }
void CompIdBase::checkId (const ExternalModelDefinition& x) { if (x.isSetId()) doCheckId(x.getId(), x); }