END_TEST START_TEST (test_SBMLConvert_convertToL2v4_DuplicateAnnotations_model) { SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(2, 1); Model_t * m = SBMLDocument_createModel(d); char * annotation = "<rdf/>\n<rdf/>"; int i = SBase_setAnnotationString((SBase_t *) (m), annotation); fail_unless( SBMLDocument_getLevel (d) == 2, NULL ); fail_unless( SBMLDocument_getVersion(d) == 1, NULL ); fail_unless( XMLNode_getNumChildren(SBase_getAnnotation((SBase_t *) (m))) == 2); fail_unless( SBMLDocument_setLevelAndVersion(d, 2, 4) == 1, NULL ); fail_unless( SBMLDocument_getLevel (d) == 2, NULL ); fail_unless( SBMLDocument_getVersion(d) == 4, NULL ); m = SBMLDocument_getModel(d); fail_unless( XMLNode_getNumChildren(SBase_getAnnotation((SBase_t *) (m))) == 1); SBMLDocument_free(d); }
END_TEST START_TEST (test_RDFAnnotation_C_parseCVTerms) { SBase_t * obj = (SBase_t *) (Model_getCompartment(m, 0)); XMLNode_t* node = RDFAnnotationParser_parseCVTerms(obj); fail_unless(XMLNode_getNumChildren(node) == 1); const XMLNode_t* rdf = XMLNode_getChild(node, 0); fail_unless(!strcmp(XMLNode_getName(rdf), "RDF")); fail_unless(!strcmp(XMLNode_getPrefix(rdf), "rdf")); fail_unless(!strcmp(XMLNode_getURI(rdf), "http://www.w3.org/1999/02/22-rdf-syntax-ns#")); fail_unless(XMLNode_getNumChildren(rdf) == 1); const XMLNode_t* desc = XMLNode_getChild(rdf, 0); fail_unless(!strcmp(XMLNode_getName(desc), "Description")); fail_unless(!strcmp(XMLNode_getPrefix(desc), "rdf")); fail_unless(!strcmp(XMLNode_getURI(desc), "http://www.w3.org/1999/02/22-rdf-syntax-ns#")); fail_unless(XMLNode_getNumChildren(desc) == 1); const XMLNode_t * is1 = XMLNode_getChild(desc, 0); fail_unless(!strcmp(XMLNode_getName(is1), "is")); fail_unless(!strcmp(XMLNode_getPrefix(is1), "bqbiol")); fail_unless(XMLNode_getNumChildren(is1) == 1); const XMLNode_t * Bag = XMLNode_getChild(is1, 0); fail_unless(!strcmp(XMLNode_getName(Bag), "Bag")); fail_unless(!strcmp(XMLNode_getPrefix(Bag), "rdf")); fail_unless(!strcmp(XMLNode_getURI(Bag), "http://www.w3.org/1999/02/22-rdf-syntax-ns#")); fail_unless(XMLNode_getNumChildren(Bag) == 4); const XMLNode_t * li = XMLNode_getChild(Bag, 0); fail_unless(!strcmp(XMLNode_getName(li), "li")); fail_unless(!strcmp(XMLNode_getPrefix(li), "rdf")); fail_unless(!strcmp(XMLNode_getURI(li), "http://www.w3.org/1999/02/22-rdf-syntax-ns#")); fail_unless(XMLNode_getNumChildren(li) == 0); const XMLNode_t * li1 = XMLNode_getChild(Bag, 1); fail_unless(!strcmp(XMLNode_getName(li1), "li")); fail_unless(!strcmp(XMLNode_getPrefix(li1), "rdf")); fail_unless(!strcmp(XMLNode_getURI(li1), "http://www.w3.org/1999/02/22-rdf-syntax-ns#")); fail_unless(XMLNode_getNumChildren(li1) == 0); const XMLNode_t * li2 = XMLNode_getChild(Bag, 2); fail_unless(!strcmp(XMLNode_getName(li2), "li")); fail_unless(!strcmp(XMLNode_getPrefix(li2), "rdf")); fail_unless(!strcmp(XMLNode_getURI(li2), "http://www.w3.org/1999/02/22-rdf-syntax-ns#")); fail_unless(XMLNode_getNumChildren(li2) == 0); const XMLNode_t * li3 = XMLNode_getChild(Bag, 3); fail_unless(!strcmp(XMLNode_getName(li3), "li")); fail_unless(!strcmp(XMLNode_getPrefix(li3), "rdf")); fail_unless(!strcmp(XMLNode_getURI(li3), "http://www.w3.org/1999/02/22-rdf-syntax-ns#")); fail_unless(XMLNode_getNumChildren(li3) == 0); XMLNode_free(node); }
END_TEST START_TEST (test_XMLNode_removeChildren) { XMLNode_t *node = XMLNode_create(); XMLNode_t *node2 = XMLNode_create(); XMLNode_t *node3 = XMLNode_create(); XMLNode_addChild(node, node2); XMLNode_addChild(node, node3); fail_unless(XMLNode_getNumChildren(node) == 2); int i = XMLNode_removeChildren(node); fail_unless( i == LIBSBML_OPERATION_SUCCESS); fail_unless(XMLNode_getNumChildren(node) == 0); XMLNode_free(node); XMLNode_free(node2); XMLNode_free(node3); }
END_TEST START_TEST (test_RDFAnnotation_C_delete) { SBase_t * obj = (SBase_t *) (Model_getCompartment(m, 0)); XMLNode_t* node = RDFAnnotationParser_parseCVTerms(obj); XMLNode_t* n1 = RDFAnnotationParser_deleteRDFAnnotation(node); fail_unless(XMLNode_getNumChildren(n1) == 0); fail_unless(!strcmp(XMLNode_getName(n1), "annotation")); XMLNode_free(node); }
CK_CPPSTART #endif START_TEST (test_XMLNode_addChild1) { XMLNode_t *node = XMLNode_create(); XMLNode_t *node2 = XMLNode_create(); int i = XMLNode_addChild(node, node2); fail_unless( i == LIBSBML_OPERATION_SUCCESS); fail_unless(XMLNode_getNumChildren(node) == 1); XMLNode_free(node); XMLNode_free(node2); }
END_TEST START_TEST (test_XMLNode_addChild3) { XMLTriple_t* triple = XMLTriple_createWith("test","",""); XMLNode_t *node = XMLNode_createEndElement(triple); XMLNode_t *node2 = XMLNode_create(); int i = XMLNode_addChild(node, node2); fail_unless( i == LIBSBML_INVALID_XML_OPERATION); fail_unless(XMLNode_getNumChildren(node) == 0); XMLTriple_free(triple); XMLNode_free(node); XMLNode_free(node2); }
END_TEST START_TEST (test_XMLNode_addChild2) { XMLTriple_t* triple = XMLTriple_createWith("test","",""); XMLAttributes_t* attr = XMLAttributes_create(); XMLNode_t *node = XMLNode_createStartElement(triple, attr); XMLNode_t *node2 = XMLNode_create(); int i = XMLNode_addChild(node, node2); fail_unless( i == LIBSBML_OPERATION_SUCCESS); fail_unless(XMLNode_getNumChildren(node) == 1); XMLTriple_free(triple); XMLAttributes_free(attr); XMLNode_free(node); XMLNode_free(node2); }
END_TEST START_TEST(test_XMLNode_accessWithNULL) { fail_unless( XMLNode_addAttr(NULL, NULL, NULL) == LIBSBML_INVALID_OBJECT ); fail_unless( XMLNode_addAttrWithNS(NULL, NULL, NULL, NULL, NULL) == LIBSBML_INVALID_OBJECT ); fail_unless( XMLNode_addAttrWithTriple(NULL, NULL, NULL) == LIBSBML_INVALID_OBJECT ); fail_unless( XMLNode_addChild(NULL, NULL) == LIBSBML_INVALID_OBJECT ); fail_unless( XMLNode_addNamespace(NULL, NULL, NULL) == LIBSBML_INVALID_OBJECT ); fail_unless( XMLNode_clearAttributes(NULL) == LIBSBML_INVALID_OBJECT ); fail_unless( XMLNode_clearNamespaces(NULL) == LIBSBML_INVALID_OBJECT ); fail_unless( XMLNode_clone(NULL) == NULL); fail_unless( XMLNode_convertStringToXMLNode(NULL, NULL) == NULL); fail_unless( XMLNode_convertXMLNodeToString(NULL) == NULL); fail_unless( XMLNode_createEndElement(NULL) == NULL); fail_unless( XMLNode_createFromToken(NULL) == NULL); fail_unless( XMLNode_createStartElement(NULL, NULL) == NULL); fail_unless( XMLNode_createStartElementNS(NULL, NULL, NULL) == NULL); fail_unless( XMLNode_equals(NULL, NULL) == 1); fail_unless( XMLNode_equals(NULL, XMLNode_createTextNode(NULL)) == 0); XMLNode_free(NULL); fail_unless( XMLNode_getAttributes(NULL) == NULL); fail_unless( XMLNode_getAttributesLength(NULL) == 0); fail_unless( XMLNode_getAttrIndex(NULL, NULL, NULL) == -1); fail_unless( XMLNode_getAttrIndexByTriple(NULL, NULL) == -1); fail_unless( XMLNode_getAttrName(NULL, 0) == NULL); fail_unless( XMLNode_getAttrPrefix(NULL, 0) == NULL); fail_unless( XMLNode_getAttrPrefixedName(NULL, 0) == NULL); fail_unless( XMLNode_getAttrURI(NULL, 0) == NULL); fail_unless( XMLNode_getAttrValue(NULL, 0) == NULL); fail_unless( XMLNode_getAttrValueByName(NULL, NULL) == NULL); fail_unless( XMLNode_getAttrValueByNS(NULL, NULL, NULL) == NULL); fail_unless( XMLNode_getAttrValueByTriple(NULL, NULL) == NULL); fail_unless( XMLNode_getCharacters(NULL) == NULL); fail_unless( XMLNode_getChild(NULL, 0) == NULL); fail_unless( XMLNode_getChildForName(NULL, NULL) == NULL); fail_unless( XMLNode_getChildForNameNC(NULL, NULL) == NULL); fail_unless( XMLNode_getChildNC(NULL, 0) == NULL); fail_unless( XMLNode_getIndex(NULL, NULL) == -1); fail_unless( XMLNode_getName(NULL) == NULL); fail_unless( XMLNode_getNamespaceIndex(NULL, NULL) == -1); fail_unless( XMLNode_getNamespaceIndexByPrefix(NULL, NULL) == -1); fail_unless( XMLNode_getNamespacePrefix(NULL, 0) == NULL); fail_unless( XMLNode_getNamespacePrefixByURI(NULL, NULL) == NULL); fail_unless( XMLNode_getNamespaces(NULL) == NULL); fail_unless( XMLNode_getNamespacesLength(NULL) == 0); fail_unless( XMLNode_getNamespaceURI(NULL, 0) == NULL); fail_unless( XMLNode_getNamespaceURIByPrefix(NULL, NULL) == NULL); fail_unless( XMLNode_getNumChildren(NULL) == 0); fail_unless( XMLNode_getPrefix(NULL) == NULL); fail_unless( XMLNode_getURI(NULL) == NULL); fail_unless( XMLNode_hasAttr(NULL, 0) == 0); fail_unless( XMLNode_hasAttrWithName(NULL, NULL) == 0); fail_unless( XMLNode_hasAttrWithNS(NULL, NULL, NULL) == 0); fail_unless( XMLNode_hasAttrWithTriple(NULL, NULL) == 0); fail_unless( XMLNode_hasChild(NULL, NULL) == 0); fail_unless( XMLNode_hasNamespaceNS(NULL, NULL, NULL) == 0); fail_unless( XMLNode_hasNamespacePrefix(NULL, NULL) == 0); fail_unless( XMLNode_hasNamespaceURI(NULL, NULL) == 0); fail_unless( XMLNode_insertChild(NULL, 0, NULL) == NULL); fail_unless( XMLNode_isAttributesEmpty(NULL) == 0); fail_unless( XMLNode_isElement(NULL) == 0); fail_unless( XMLNode_isEnd(NULL) == 0); fail_unless( XMLNode_isEndFor(NULL, NULL) == 0); fail_unless( XMLNode_isEOF(NULL) == 0); fail_unless( XMLNode_isNamespacesEmpty(NULL) == 0); fail_unless( XMLNode_isStart(NULL) == 0); fail_unless( XMLNode_isText(NULL) == 0); fail_unless( XMLNode_removeAttr(NULL, 0) == LIBSBML_INVALID_OBJECT); fail_unless( XMLNode_removeAttrByName(NULL, NULL) == LIBSBML_INVALID_OBJECT); fail_unless( XMLNode_removeAttrByNS(NULL, NULL, NULL) == LIBSBML_INVALID_OBJECT); fail_unless( XMLNode_removeAttrByTriple(NULL, NULL) == LIBSBML_INVALID_OBJECT); fail_unless( XMLNode_removeChild(NULL, 0) == NULL); fail_unless( XMLNode_removeChildren(NULL) == LIBSBML_INVALID_OBJECT); fail_unless( XMLNode_removeNamespace(NULL, 0) == LIBSBML_INVALID_OBJECT); fail_unless( XMLNode_removeNamespaceByPrefix(NULL, NULL) == LIBSBML_INVALID_OBJECT); fail_unless( XMLNode_setAttributes(NULL, NULL) == LIBSBML_INVALID_OBJECT); fail_unless( XMLNode_setEnd(NULL) == LIBSBML_INVALID_OBJECT); fail_unless( XMLNode_setEOF(NULL) == LIBSBML_INVALID_OBJECT); fail_unless( XMLNode_setNamespaces(NULL, NULL) == LIBSBML_INVALID_OBJECT); fail_unless( XMLNode_setTriple(NULL, NULL) == LIBSBML_INVALID_OBJECT); fail_unless( XMLNode_toXMLString(NULL) == NULL); fail_unless( XMLNode_unsetEnd(NULL) == LIBSBML_INVALID_OBJECT); }
END_TEST START_TEST (test_RDFAnnotation_C_parseModelHistory) { XMLNode_t* node = RDFAnnotationParser_parseModelHistory((SBase_t *) m); fail_unless(XMLNode_getNumChildren(node) == 1); const XMLNode_t* rdf = XMLNode_getChild(node, 0); fail_unless(!strcmp(XMLNode_getName(rdf), "RDF")); fail_unless(!strcmp(XMLNode_getPrefix(rdf), "rdf")); fail_unless(!strcmp(XMLNode_getURI(rdf), "http://www.w3.org/1999/02/22-rdf-syntax-ns#")); fail_unless(XMLNode_getNumChildren(rdf) == 1); const XMLNode_t* desc = XMLNode_getChild(rdf, 0); fail_unless(!strcmp(XMLNode_getName(desc), "Description")); fail_unless(!strcmp(XMLNode_getPrefix(desc), "rdf")); fail_unless(!strcmp(XMLNode_getURI(desc), "http://www.w3.org/1999/02/22-rdf-syntax-ns#")); fail_unless(XMLNode_getNumChildren(desc) == 3); const XMLNode_t * creator = XMLNode_getChild(desc, 0); fail_unless(!strcmp(XMLNode_getName(creator), "creator")); fail_unless(!strcmp(XMLNode_getPrefix(creator), "dc")); fail_unless(!strcmp(XMLNode_getURI(creator), "http://purl.org/dc/elements/1.1/")); fail_unless(XMLNode_getNumChildren(creator) == 1); const XMLNode_t * Bag = XMLNode_getChild(creator, 0); fail_unless(!strcmp(XMLNode_getName(Bag), "Bag")); fail_unless(!strcmp(XMLNode_getPrefix(Bag), "rdf")); fail_unless(!strcmp(XMLNode_getURI(Bag), "http://www.w3.org/1999/02/22-rdf-syntax-ns#")); fail_unless(XMLNode_getNumChildren(Bag) == 1); const XMLNode_t * li = XMLNode_getChild(Bag, 0); fail_unless(!strcmp(XMLNode_getName(li), "li")); fail_unless(!strcmp(XMLNode_getPrefix(li), "rdf")); fail_unless(!strcmp(XMLNode_getURI(li), "http://www.w3.org/1999/02/22-rdf-syntax-ns#")); fail_unless(XMLNode_getNumChildren(li) == 3); const XMLNode_t *N = XMLNode_getChild(li, 0); fail_unless(!strcmp(XMLNode_getName(N), "N")); fail_unless(!strcmp(XMLNode_getPrefix(N), "vCard")); fail_unless(!strcmp(XMLNode_getURI(N), "http://www.w3.org/2001/vcard-rdf/3.0#")); fail_unless(XMLNode_getNumChildren(N) == 2); const XMLNode_t *Family = XMLNode_getChild(N, 0); fail_unless(!strcmp(XMLNode_getName(Family), "Family")); fail_unless(!strcmp(XMLNode_getPrefix(Family), "vCard")); fail_unless(!strcmp(XMLNode_getURI(Family), "http://www.w3.org/2001/vcard-rdf/3.0#")); fail_unless(XMLNode_getNumChildren(Family) == 1); const XMLNode_t *Given = XMLNode_getChild(N, 1); fail_unless(!strcmp(XMLNode_getName(Given), "Given")); fail_unless(!strcmp(XMLNode_getPrefix(Given), "vCard")); fail_unless(!strcmp(XMLNode_getURI(Given), "http://www.w3.org/2001/vcard-rdf/3.0#")); fail_unless(XMLNode_getNumChildren(Given) == 1); const XMLNode_t *EMAIL = XMLNode_getChild(li, 1); fail_unless(!strcmp(XMLNode_getName(EMAIL), "EMAIL")); fail_unless(!strcmp(XMLNode_getPrefix(EMAIL), "vCard")); fail_unless(!strcmp(XMLNode_getURI(EMAIL), "http://www.w3.org/2001/vcard-rdf/3.0#")); fail_unless(XMLNode_getNumChildren(EMAIL) == 1); const XMLNode_t *ORG = XMLNode_getChild(li, 2); fail_unless(!strcmp(XMLNode_getName(ORG), "ORG")); fail_unless(!strcmp(XMLNode_getPrefix(ORG), "vCard")); fail_unless(!strcmp(XMLNode_getURI(ORG), "http://www.w3.org/2001/vcard-rdf/3.0#")); fail_unless(XMLNode_getNumChildren(ORG) == 1); const XMLNode_t *Orgname = XMLNode_getChild(ORG, 0); fail_unless(!strcmp(XMLNode_getName(Orgname), "Orgname")); fail_unless(!strcmp(XMLNode_getPrefix(Orgname), "vCard")); fail_unless(!strcmp(XMLNode_getURI(Orgname), "http://www.w3.org/2001/vcard-rdf/3.0#")); fail_unless(XMLNode_getNumChildren(Orgname) == 1); const XMLNode_t * created = XMLNode_getChild(desc, 1); fail_unless(!strcmp(XMLNode_getName(created), "created")); fail_unless(!strcmp(XMLNode_getPrefix(created), "dcterms")); fail_unless(!strcmp(XMLNode_getURI(created), "http://purl.org/dc/terms/")); fail_unless(XMLNode_getNumChildren(created) == 1); const XMLNode_t * cr_date = XMLNode_getChild(created, 0); fail_unless(!strcmp(XMLNode_getName(cr_date), "W3CDTF")); fail_unless(!strcmp(XMLNode_getPrefix(cr_date), "dcterms")); fail_unless(!strcmp(XMLNode_getURI(cr_date), "http://purl.org/dc/terms/")); fail_unless(XMLNode_getNumChildren(cr_date) == 1); const XMLNode_t * modified = XMLNode_getChild(desc, 2); fail_unless(!strcmp(XMLNode_getName(modified), "modified")); fail_unless(!strcmp(XMLNode_getPrefix(modified), "dcterms")); fail_unless(!strcmp(XMLNode_getURI(modified), "http://purl.org/dc/terms/")); fail_unless(XMLNode_getNumChildren(modified) == 1); const XMLNode_t * mo_date = XMLNode_getChild(created, 0); fail_unless(!strcmp(XMLNode_getName(mo_date), "W3CDTF")); fail_unless(!strcmp(XMLNode_getPrefix(mo_date), "dcterms")); fail_unless(!strcmp(XMLNode_getURI(mo_date), "http://purl.org/dc/terms/")); fail_unless(XMLNode_getNumChildren(mo_date) == 1); XMLNode_free(node); }