END_TEST START_TEST (test_Constraint_setMessage2) { //const char * expected = ( // "<message>\n" // " <p xmlns=\"http://www.w3.org/1999/xhtml\"> Some text </p>\n" // "</message>"); XMLNode_t *text = XMLNode_convertStringToXMLNode(" Some text ", NULL); XMLTriple_t *triple = XMLTriple_createWith("p", "http://www.w3.org/1999/xhtml", ""); XMLAttributes_t *att = XMLAttributes_create(); XMLNamespaces_t *xmlns = XMLNamespaces_create(); XMLNamespaces_add(xmlns, "http://www.w3.org/1999/xhtml", ""); XMLNode_t *p = XMLNode_createStartElementNS(triple, att, xmlns); XMLNode_addChild(p, text); XMLTriple_t *triple1 = XMLTriple_createWith("message", "", ""); XMLAttributes_t *att1 = XMLAttributes_create(); XMLNode_t *node = XMLNode_createStartElement(triple1, att1); XMLNode_addChild(node, p); int i = Constraint_setMessage(C, node); fail_unless(i == LIBSBML_OPERATION_SUCCESS); fail_unless( Constraint_isSetMessage(C) == 1); /* FIX ME printf("Expected: %s\n", expected); printf("String : %s\n", Constraint_getMessage(C)); fail_unless( strcmp(Constraint_getMessageString(C), expected) == 0); */ i = Constraint_unsetMessage(C); fail_unless(i == LIBSBML_OPERATION_SUCCESS); fail_unless( !Constraint_isSetMessage(C) ); if (Constraint_getMessage(C) != NULL) { fail("Constraint_unsetMessage(C) did not clear XMLNode."); } XMLNode_free(text); XMLTriple_free(triple); XMLAttributes_free(att); XMLNamespaces_free(xmlns); XMLNode_free(p); XMLTriple_free(triple1); XMLAttributes_free(att1); XMLNode_free(node); }
END_TEST START_TEST (test_Constraint_setMessage) { XMLNode_t *text = XMLNode_convertStringToXMLNode(" Some text ", NULL); XMLTriple_t *triple = XMLTriple_createWith("p", "http://www.w3.org/1999/xhtml", ""); XMLAttributes_t *att = XMLAttributes_create(); XMLNamespaces_t *xmlns = XMLNamespaces_create(); XMLNamespaces_add(xmlns, "http://www.w3.org/1999/xhtml", ""); XMLNode_t *p = XMLNode_createStartElementNS(triple, att, xmlns); XMLNode_addChild(p, text); XMLTriple_t *triple1 = XMLTriple_createWith("message", "", ""); XMLAttributes_t *att1 = XMLAttributes_create(); XMLNode_t *node = XMLNode_createStartElement(triple1, att1); XMLNode_addChild(node, p); Constraint_setMessage(C, node); fail_unless( Constraint_getMessage(C) != node ); fail_unless( Constraint_isSetMessage(C) == 1); /* Reflexive case (pathological) */ Constraint_setMessage(C, (XMLNode_t *) Constraint_getMessage(C)); fail_unless( Constraint_getMessage(C) != node ); char* str = Constraint_getMessageString(C) ; fail_unless( str != NULL ); safe_free(str); Constraint_unsetMessage(C); fail_unless( !Constraint_isSetMessage(C) ); if (Constraint_getMessage(C) != NULL) { fail("Constraint_unsetMessage(C) did not clear XMLNode."); } XMLNode_free(text); XMLTriple_free(triple); XMLAttributes_free(att); XMLNamespaces_free(xmlns); XMLNode_free(p); XMLTriple_free(triple1); XMLAttributes_free(att1); XMLNode_free(node); }
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); }