END_TEST START_TEST (test_SyntaxChecker_validXHTML) { SBMLNamespaces_t *NS24 = SBMLNamespaces_create(2,4); SBMLNamespaces_t *NS31 = SBMLNamespaces_create(3,1); XMLToken_t *toptoken; XMLNode_t *topnode; XMLTriple_t * toptriple = XMLTriple_createWith("notes", "", ""); XMLToken_t *token; XMLNode_t *node; XMLTriple_t * triple = XMLTriple_createWith("p", "", ""); XMLAttributes_t * att = XMLAttributes_create (); XMLNamespaces_t *ns = XMLNamespaces_create(); XMLNamespaces_add(ns, "http://www.w3.org/1999/xhtml", ""); XMLToken_t *tt = XMLToken_createWithText("This is my text"); XMLNode_t *n1 = XMLNode_createFromToken(tt); toptoken = XMLToken_createWithTripleAttr(toptriple, att); topnode = XMLNode_createFromToken(toptoken); token = XMLToken_createWithTripleAttrNS(triple, att, ns); node = XMLNode_createFromToken(token); XMLNode_addChild(node, n1); XMLNode_addChild(topnode, node); fail_unless( SyntaxChecker_hasExpectedXHTMLSyntax(topnode, NULL) == 1 ); fail_unless( SyntaxChecker_hasExpectedXHTMLSyntax(topnode, NS24) == 1 ); fail_unless( SyntaxChecker_hasExpectedXHTMLSyntax(topnode, NS31) == 1 ); triple = XMLTriple_createWith("html", "", ""); token = XMLToken_createWithTripleAttrNS(triple, att, ns); node = XMLNode_createFromToken(token); XMLNode_addChild(node, n1); XMLNode_removeChild(topnode, 0); XMLNode_addChild(topnode, node); fail_unless( SyntaxChecker_hasExpectedXHTMLSyntax(topnode, NULL) == 1 ); fail_unless( SyntaxChecker_hasExpectedXHTMLSyntax(topnode, NS24) == 0 ); fail_unless( SyntaxChecker_hasExpectedXHTMLSyntax(topnode, NS31) == 1 ); triple = XMLTriple_createWith("html", "", ""); XMLNamespaces_clear(ns); token = XMLToken_createWithTripleAttrNS(triple, att, ns); node = XMLNode_createFromToken(token); XMLNode_addChild(node, n1); XMLNode_removeChild(topnode, 0); XMLNode_addChild(topnode, node); fail_unless( SyntaxChecker_hasExpectedXHTMLSyntax(topnode, NULL) == 0 ); fail_unless( SyntaxChecker_hasExpectedXHTMLSyntax(topnode, NS24) == 0 ); fail_unless( SyntaxChecker_hasExpectedXHTMLSyntax(topnode, NS31) == 0 ); }
END_TEST START_TEST (test_XMLNamespaces_clear) { XMLNamespaces_add(NS, "http://test1.org/", "test1"); XMLNamespaces_add(NS, "http://test2.org/", "test2"); XMLNamespaces_add(NS, "http://test3.org/", "test3"); XMLNamespaces_add(NS, "http://test4.org/", "test4"); XMLNamespaces_add(NS, "http://test5.org/", "test5"); fail_unless( XMLNamespaces_getLength(NS) == 5 ); int i = XMLNamespaces_clear(NS); fail_unless( i == LIBSBML_OPERATION_SUCCESS); fail_unless( XMLNamespaces_getLength(NS) == 0 ); }
END_TEST START_TEST (test_XMLNamespaces_accessWithNULL) { fail_unless( XMLNamespaces_add(NULL, NULL, NULL) == LIBSBML_INVALID_OBJECT); fail_unless( XMLNamespaces_clear(NULL) == LIBSBML_OPERATION_FAILED); fail_unless( XMLNamespaces_clone(NULL) == NULL); XMLNamespaces_free(NULL); fail_unless( XMLNamespaces_getIndex(NULL, NULL) == -1); fail_unless( XMLNamespaces_getIndexByPrefix(NULL, NULL) == -1); fail_unless( XMLNamespaces_getLength(NULL) == 0); fail_unless( XMLNamespaces_getPrefix(NULL, 0) == NULL); fail_unless( XMLNamespaces_getPrefixByURI(NULL, NULL) == NULL); fail_unless( XMLNamespaces_getURI(NULL, 0) == NULL); fail_unless( XMLNamespaces_getURIByPrefix(NULL, NULL) == NULL); fail_unless( XMLNamespaces_hasNS(NULL, NULL, NULL) == 0); fail_unless( XMLNamespaces_hasPrefix(NULL, NULL) == 0); fail_unless( XMLNamespaces_hasURI(NULL, NULL) == 0); fail_unless( XMLNamespaces_isEmpty(NULL) == 1); fail_unless( XMLNamespaces_remove(NULL, 0) == LIBSBML_INVALID_OBJECT); fail_unless( XMLNamespaces_removeByPrefix(NULL, NULL) == LIBSBML_INVALID_OBJECT); }