END_TEST START_TEST (test_GroupsModelPlugin_copyNesting2) { //GroupsPkgNamespaces gpn; //SBMLDocument doc(&gpn); char *filename = safe_strcat(TestDataDirectory, "groups-nested1.xml"); SBMLDocument *document = readSBMLFromFile(filename); Model* model = document->getModel(); fail_unless(model != NULL); GroupsModelPlugin* mplugin = static_cast<GroupsModelPlugin*>(model->getPlugin("groups")); fail_unless(mplugin != NULL); fail_unless(mplugin->getNumGroups() == 4); Group* group1 = mplugin->getGroup(0); Group* group2 = mplugin->getGroup(1); Group* group3 = mplugin->getGroup(2); Group* group4 = mplugin->getGroup(3); group3->getListOfMembers()->setSBOTerm(5); mplugin->copyInformationToNestedLists(); fail_unless(!group1->getListOfMembers()->isSetSBOTerm()); fail_unless( group2->getListOfMembers()->getSBOTerm() == 5); fail_unless( group3->getListOfMembers()->getSBOTerm() == 5); fail_unless( group4->getListOfMembers()->getSBOTerm() == 252); group4->getListOfMembers()->setNotes("These are some notes, v1.", true); group3->getListOfMembers()->setNotes("These are some notes, v2.", true); mplugin->copyInformationToNestedLists(); fail_unless(!group1->getListOfMembers()->isSetNotes()); fail_unless( group2->getListOfMembers()->getNotesString().find("These are some notes, v2.") != string::npos); fail_unless( group3->getListOfMembers()->getNotesString().find("These are some notes, v2.") != string::npos); fail_unless( group4->getListOfMembers()->getNotesString().find("These are some notes, v1.") != string::npos); group4->getListOfMembers()->setAnnotation("This is a malformed annotation, v1."); group3->getListOfMembers()->setAnnotation("This is a malformed annotation, v2."); mplugin->copyInformationToNestedLists(); fail_unless(!group1->getListOfMembers()->isSetAnnotation()); fail_unless( group2->getListOfMembers()->getAnnotationString().find("This is a malformed annotation, v2.") != string::npos); fail_unless( group3->getListOfMembers()->getAnnotationString().find("This is a malformed annotation, v2.") != string::npos); fail_unless( group4->getListOfMembers()->getAnnotationString().find("This is a malformed annotation, v1.") != string::npos); delete document; safe_free((void*)(filename)); }
END_TEST START_TEST (test_GroupsExtension_read_L3V1V1_defaultNS) { char *filename = safe_strcat(TestDataDirectory, "groups-example1-defaultNS.xml"); SBMLDocument *document = readSBMLFromFile(filename); fail_unless(document->getPackageName() == "core"); Model *model = document->getModel(); document->printErrors(); fail_unless(model != NULL); fail_unless(document->getNumErrors() == 0); // get the Group GroupsModelPlugin* mplugin = static_cast<GroupsModelPlugin*>(model->getPlugin("groups")); fail_unless(mplugin != NULL); fail_unless(mplugin->getNumGroups() == 1); fail_unless(mplugin->getListOfGroups()->getPackageName() == "groups"); Group* group = mplugin->getGroup(0); fail_unless(group->getId() == "ATP"); fail_unless(group->getSBOTermID() == "SBO:0000252"); fail_unless(group->getKind() == GROUP_KIND_CLASSIFICATION); fail_unless(group->isSetKind() == true); fail_unless(!strcmp(GroupKind_toString(group->getKind()), "classification")); fail_unless(group->getNumMembers() == 2); fail_unless(group->getPackageName() == "groups"); fail_unless(group->getListOfMembers()->getPackageName() == "groups"); Member* member = group->getMember(0); fail_unless(member->getIdRef() == "ATPc"); fail_unless(member->getPackageName() == "groups"); member = group->getMember(1); fail_unless(member->getIdRef() == "ATPm"); fail_unless(member->getPackageName() == "groups"); delete document; safe_free(filename); }
END_TEST START_TEST (test_GroupsExtension_read_memberConstraints) { char *filename = safe_strcat(TestDataDirectory, "groups_speciestype_example.xml"); SBMLDocument *document = readSBMLFromFile(filename); fail_unless(document->getPackageName() == "core"); Model *model = document->getModel(); fail_unless(model != NULL); fail_unless(model->getPackageName() == "core"); fail_unless(document->getNumErrors() == 0); // get the Group GroupsModelPlugin* mplugin = static_cast<GroupsModelPlugin*>(model->getPlugin("groups")); fail_unless(mplugin != NULL); fail_unless(mplugin->getNumGroups() == 1); fail_unless(mplugin->getListOfGroups()->getPackageName() == "groups"); Group* group = mplugin->getGroup(0); fail_unless(group->getId() == "ATP"); fail_unless(group->getKind() == GROUP_KIND_CLASSIFICATION); fail_unless(group->getNumMembers() == 2); fail_unless(group->getNumMemberConstraints() == 3); fail_unless(group->getPackageName() == "groups"); fail_unless(group->getListOfMembers()->getPackageName() == "groups"); fail_unless(group->getListOfMembers()->getSBOTermID() == "SBO:0000248"); Member* member = group->getMember(0); fail_unless(member->getIdRef() == "ATPc"); fail_unless(member->getPackageName() == "groups"); member = group->getMember(1); fail_unless(member->getIdRef() == "ATPm"); fail_unless(member->getPackageName() == "groups"); ListOfMemberConstraints* lomcs = group->getListOfMemberConstraints(); fail_unless(lomcs->getPackageName() == "groups"); fail_unless(lomcs->isSetMembersShareType() == true); fail_unless(lomcs->getMembersShareType() == true); MemberConstraint* mc = group->getMemberConstraint(0); fail_unless(mc->isSetDistinctAttribute() == true); fail_unless(mc->isSetIdenticalAttribute() == false); fail_unless(mc->getDistinctAttribute() == "compartment"); fail_unless(mc->getPackageName() == "groups"); mc = group->getMemberConstraint(1); fail_unless(mc->isSetDistinctAttribute() == false); fail_unless(mc->isSetIdenticalAttribute() == true); fail_unless(mc->getIdenticalAttribute() == "initialConcentration"); fail_unless(mc->getPackageName() == "groups"); mc = group->getMemberConstraint(2); fail_unless(mc->isSetDistinctAttribute() == false); fail_unless(mc->isSetIdenticalAttribute() == true); fail_unless(mc->getIdenticalAttribute() == "constant"); fail_unless(mc->getPackageName() == "groups"); delete document; }