コード例 #1
0
LIBLAX_CPP_NAMESPACE_USE
CK_CPPSTART
#endif

START_TEST(test_XMLToken_newSetters_setAttributes1)
{
  /*-- setup --*/

  XMLTriple_t*     triple = XMLTriple_createWith("test","","");
  XMLAttributes_t* attr   = XMLAttributes_create();
  XMLToken_t*      token  = XMLToken_createWithTripleAttr(triple, attr);
  XMLAttributes_t* nattr  = XMLAttributes_create();

  XMLTriple_t* xt1    = XMLTriple_createWith("name1", "http://name1.org/", "p1");

  XMLAttributes_addWithTriple(nattr, xt1, "val1");

  /*-- test of setting attributes -- */

  int i = XMLToken_setAttributes(token, nattr);

  fail_unless ( i == LIBSBML_OPERATION_SUCCESS);
  fail_unless(XMLToken_isAttributesEmpty(token)   == 0 );

  /*-- teardown --*/

  XMLAttributes_free(nattr);
  XMLAttributes_free(attr);
  XMLTriple_free(triple);
  XMLToken_free(token);
  XMLTriple_free(xt1);
}
コード例 #2
0
END_TEST


START_TEST (test_XMLToken_newSetters_removeNamespaces1)
{
  XMLTriple_t*     triple = XMLTriple_createWith("test","","");
  XMLAttributes_t* attr   = XMLAttributes_create();
  XMLToken_t*      token  = XMLToken_createWithTripleAttr(triple, attr);

  XMLToken_addNamespace(token, "http://test1.org/", "test1"); 

  fail_unless( XMLToken_getNamespacesLength(token) == 1 );
  
  int i = XMLToken_removeNamespaceByPrefix(token, "test2");
  
  fail_unless( i == LIBSBML_INDEX_EXCEEDS_SIZE);
  fail_unless( XMLToken_getNamespacesLength(token) == 1 );
  
  i = XMLToken_removeNamespaceByPrefix(token, "test1");

  fail_unless( i == LIBSBML_OPERATION_SUCCESS);
  fail_unless( XMLToken_getNamespacesLength(token) == 0 );

  XMLToken_free(token);
  XMLTriple_free(triple);
  XMLAttributes_free(attr);
}
コード例 #3
0
END_TEST


START_TEST(test_XMLToken_newSetters_addNamespaces2)
{
  /*-- setup --*/

  XMLTriple_t*     triple = XMLTriple_createWith("test","","");
  XMLToken_t*      token  = XMLToken_createWithTriple(triple);
  
  fail_unless( XMLToken_getNamespacesLength(token) == 0 );
  fail_unless( XMLToken_isNamespacesEmpty(token)   == 1 );  

  /*-- test of setting namespaces -- */
  int i =   XMLToken_addNamespace(token, "http://test1.org/", "test1");

  fail_unless ( i == LIBSBML_INVALID_XML_OPERATION);
  fail_unless( XMLToken_getNamespacesLength(token) == 0 );
  fail_unless( XMLToken_isNamespacesEmpty(token)   == 1 );  

  /*-- teardown --*/

  XMLTriple_free(triple);
  XMLToken_free(token);
}
コード例 #4
0
END_TEST


START_TEST(test_XMLToken_newSetters_setTriple2)
{
  int i;
  /*-- setup --*/

  XMLTriple_t*     triple = XMLTriple_createWith("test","","");
  XMLToken_t *token = XMLToken_createWithText("This is text");
  
    
  /*-- test of setting triple with NULL value -- */
  i = XMLToken_setTriple(token, NULL);

  fail_unless ( i == LIBSBML_INVALID_OBJECT);

  
  /*-- test of setting triple -- */
  i =   XMLToken_setTriple(token, triple);

  fail_unless ( i == LIBSBML_INVALID_XML_OPERATION);

  /*-- teardown --*/

  XMLTriple_free(triple);
  XMLToken_free(token);
}
コード例 #5
0
END_TEST


START_TEST(test_XMLToken_newSetters_setNamespaces1)
{
  /*-- setup --*/

  XMLTriple_t*     triple = XMLTriple_createWith("test","","");
  XMLAttributes_t* attr   = XMLAttributes_create();
  XMLToken_t*      token  = XMLToken_createWithTripleAttr(triple, attr);
  XMLNamespaces_t* ns = XMLNamespaces_create();

  fail_unless( XMLToken_getNamespacesLength(token) == 0 );
  fail_unless( XMLToken_isNamespacesEmpty(token)   == 1 );  

  /*-- test of setting namespaces -- */
  XMLNamespaces_add(ns, "http://test1.org/", "test1"); 

  int i =   XMLToken_setNamespaces(token, ns);

  fail_unless ( i == LIBSBML_OPERATION_SUCCESS);
  fail_unless( XMLToken_getNamespacesLength(token) == 1 );
  fail_unless( XMLToken_isNamespacesEmpty(token)   == 0 );  

  /*-- teardown --*/

  XMLAttributes_free(attr);
  XMLTriple_free(triple);
  XMLToken_free(token);
  XMLNamespaces_free(ns);
}
コード例 #6
0
END_TEST


START_TEST(test_XMLToken_newSetters_addAttributes1)
{
  /*-- setup --*/

  XMLTriple_t*     triple = XMLTriple_createWith("test","","");
  XMLAttributes_t* attr   = XMLAttributes_create();
  XMLToken_t*      token  = XMLToken_createWithTripleAttr(triple, attr);

  XMLTriple_t* xt2    = XMLTriple_createWith("name3", 
                                             "http://name3.org/", "p3");
  /*-- test of adding attributes --*/

  int i = XMLToken_addAttr(token, "name1", "val1");

  fail_unless( i == LIBSBML_OPERATION_SUCCESS );
  fail_unless( XMLToken_getAttributesLength(token) == 1 );
  fail_unless( XMLToken_isAttributesEmpty(token)   == 0 );

  fail_unless( strcmp(XMLToken_getAttrName  (token, 0), "name1") == 0 );
  fail_unless( strcmp(XMLToken_getAttrValue (token, 0), "val1" ) == 0 );

  i = XMLToken_addAttrWithNS(token, "name2", "val2", 
                                             "http://name1.org/", "p1");

  fail_unless( i == LIBSBML_OPERATION_SUCCESS );
  fail_unless( XMLToken_getAttributesLength(token) == 2 );
  fail_unless( XMLToken_isAttributesEmpty(token)   == 0 );

  fail_unless( strcmp(XMLToken_getAttrName  (token, 1), "name2") == 0 );
  fail_unless( strcmp(XMLToken_getAttrValue (token, 1), "val2" ) == 0 );
  fail_unless( strcmp(XMLToken_getAttrURI   (token, 1), "http://name1.org/") == 0 );
  fail_unless( strcmp(XMLToken_getAttrPrefix(token, 1), "p1"   ) == 0 );

  i = XMLToken_addAttrWithTriple(token, xt2, "val2");

  fail_unless( i == LIBSBML_OPERATION_SUCCESS );
  fail_unless( XMLToken_getAttributesLength(token) == 3 );
  fail_unless( XMLToken_isAttributesEmpty(token)   == 0 );
  fail_unless( strcmp(XMLToken_getAttrName  (token, 2), "name3") == 0 );
  fail_unless( strcmp(XMLToken_getAttrValue (token, 2), "val2" ) == 0 );
  fail_unless( strcmp(XMLToken_getAttrURI   (token, 2), "http://name3.org/") == 0 );
  fail_unless( strcmp(XMLToken_getAttrPrefix(token, 2), "p3"   ) == 0 );

  /*-- teardown --*/

  XMLTriple_free(xt2);
  XMLTriple_free(triple);
  XMLAttributes_free(attr);
  XMLToken_free(token);
}
コード例 #7
0
END_TEST


START_TEST(test_XMLToken_newSetters_setTriple1)
{
  /*-- setup --*/

  XMLTriple_t*     triple = XMLTriple_createWith("test","","");
  XMLToken_t*      token  = XMLToken_create();
  
  /*-- test of setting triple -- */
  int i =   XMLToken_setTriple(token, triple);

  fail_unless ( i == LIBSBML_OPERATION_SUCCESS);
  fail_unless( !strcmp(XMLToken_getName(token), "test") );

  /*-- teardown --*/

  XMLTriple_free(triple);
  XMLToken_free(token);
}
コード例 #8
0
END_TEST


START_TEST(test_XMLToken_newSetters_setEOF)
{
  /*-- setup --*/

  XMLToken_t*      token  = XMLToken_create();
  fail_unless( XMLToken_isEnd(token) == 0 );
  
  /*-- test of setting eof -- */
  int i =   XMLToken_setEOF(token);

  fail_unless ( i == LIBSBML_OPERATION_SUCCESS);
  fail_unless( XMLToken_isEnd(token) == 0 );
  fail_unless( XMLToken_isStart(token) == 0 );
  fail_unless( XMLToken_isText(token) == 0 );

  /*-- teardown --*/

  XMLToken_free(token);
}
コード例 #9
0
END_TEST


START_TEST(test_XMLToken_newSetters_addAttributes2)
{
  /*-- setup --*/

  XMLTriple_t*     triple = XMLTriple_createWith("test","","");
  XMLToken_t*      token  = XMLToken_createWithTriple(triple);

  XMLTriple_t* xt2    = XMLTriple_createWith("name3", 
                                             "http://name3.org/", "p3");
  /*-- test of adding attributes --*/

  int i = XMLToken_addAttr(token, "name1", "val1");

  fail_unless( i == LIBSBML_INVALID_XML_OPERATION );
  fail_unless( XMLToken_getAttributesLength(token) == 0 );
  fail_unless( XMLToken_isAttributesEmpty(token)   == 1 );

  i = XMLToken_addAttrWithNS(token, "name2", "val2", 
                                             "http://name1.org/", "p1");

  fail_unless( i == LIBSBML_INVALID_XML_OPERATION );
  fail_unless( XMLToken_getAttributesLength(token) == 0 );
  fail_unless( XMLToken_isAttributesEmpty(token)   == 1 );

  i = XMLToken_addAttrWithTriple(token, xt2, "val2");

  fail_unless( i == LIBSBML_INVALID_XML_OPERATION );
  fail_unless( XMLToken_getAttributesLength(token) == 0 );
  fail_unless( XMLToken_isAttributesEmpty(token)   == 1 );

  /*-- teardown --*/

  XMLTriple_free(xt2);
  XMLTriple_free(triple);
  XMLToken_free(token);
}
コード例 #10
0
END_TEST


START_TEST(test_XMLToken_newSetters_setNamespaces2)
{
  int i;
  /*-- setup --*/

  XMLTriple_t*     triple = XMLTriple_createWith("test","","");
  XMLToken_t*      token  = XMLToken_createWithTriple(triple);
  XMLNamespaces_t* ns = XMLNamespaces_create();

  fail_unless( XMLToken_getNamespacesLength(token) == 0 );
  fail_unless( XMLToken_isNamespacesEmpty(token)   == 1 );  

  /*-- test of setting namespaces -- */
  XMLNamespaces_add(ns, "http://test1.org/", "test1"); 

  
  /*-- test of setting namespaces with NULL value -- */
  i = XMLToken_setNamespaces(token, NULL);

  fail_unless ( i == LIBSBML_INVALID_OBJECT);


  /*-- test of setting namespaces -- */
  i =   XMLToken_setNamespaces(token, ns);

  fail_unless ( i == LIBSBML_INVALID_XML_OPERATION);
  fail_unless( XMLToken_getNamespacesLength(token) == 0 );
  fail_unless( XMLToken_isNamespacesEmpty(token)   == 1 );  

  /*-- teardown --*/

  XMLTriple_free(triple);
  XMLToken_free(token);
  XMLNamespaces_free(ns);
}
コード例 #11
0
END_TEST


START_TEST(test_XMLToken_newSetters_setAttributes2)
{
  int i ;
  /*-- setup --*/

  XMLTriple_t*     triple = XMLTriple_createWith("test","","");
  XMLToken_t*      token  = XMLToken_createWithTriple(triple);
  XMLAttributes_t* nattr  = XMLAttributes_create();

  XMLTriple_t* xt1    = XMLTriple_createWith("name1", "http://name1.org/", "p1");

  XMLAttributes_addWithTriple(nattr, xt1, "val1");

  /*-- test of setting attributes with NULL value -- */
  i = XMLToken_setAttributes(token, NULL);

  fail_unless ( i == LIBSBML_INVALID_OBJECT);

  /*-- test of setting attributes -- */

  i = XMLToken_setAttributes(token, nattr);

  fail_unless ( i == LIBSBML_INVALID_XML_OPERATION);
  fail_unless(XMLToken_isAttributesEmpty(token)   == 1 );


  /*-- teardown --*/

  XMLAttributes_free(nattr);
  XMLTriple_free(triple);
  XMLToken_free(token);
  XMLTriple_free(xt1);
}
コード例 #12
0
END_TEST


START_TEST (test_SyntaxChecker_validXHTML)
{
  SBMLNamespaces_t *NS24 = SBMLNamespaces_create(2,4);
  SBMLNamespaces_t *NS31 = SBMLNamespaces_create(3,1);

  XMLTriple_t * toptriple = XMLTriple_createWith("notes", "", "");
  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);
  XMLToken_t *toptoken = XMLToken_createWithTripleAttr(toptriple, att);
  XMLNode_t *topnode = XMLNode_createFromToken(toptoken);
  XMLToken_t *token = XMLToken_createWithTripleAttrNS(triple, att, ns);
  XMLNode_t *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 );

  XMLTriple_free(triple);
  XMLToken_free(token);
  XMLNode_free(node);
  triple = XMLTriple_createWith("html", "", "");
  token = XMLToken_createWithTripleAttrNS(triple, att, ns);
  node = XMLNode_createFromToken(token);
  XMLNode_addChild(node, n1);
  XMLNode_free(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 );

  XMLTriple_free(triple);
  triple = XMLTriple_createWith("html", "", "");
  XMLNamespaces_clear(ns);

  XMLToken_free(token);
  XMLNode_free(node);
  token = XMLToken_createWithTripleAttrNS(triple, att, ns);
  node = XMLNode_createFromToken(token);
  XMLNode_addChild(node, n1);
  XMLNode_free(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 );

  SBMLNamespaces_free(NS24);
  SBMLNamespaces_free(NS31);
  XMLTriple_free(toptriple);
  XMLTriple_free(triple);
  XMLAttributes_free(att);
  XMLNamespaces_free(ns);
  XMLToken_free(tt);
  XMLNode_free(n1);
  XMLToken_free(toptoken);
  XMLNode_free(topnode);
  XMLToken_free(token);
  XMLNode_free(node);
}
コード例 #13
0
END_TEST


START_TEST(test_XMLToken_newSetters_removeAttributes1)
{
  /*-- setup --*/

  XMLTriple_t*     triple = XMLTriple_createWith("test","","");
  XMLAttributes_t* attr   = XMLAttributes_create();
  XMLToken_t*      token  = XMLToken_createWithTripleAttr(triple, attr);

  XMLTriple_t* xt2    = XMLTriple_createWith("name3", 
                                             "http://name3.org/", "p3");
  XMLTriple_t* xt1    = XMLTriple_createWith("name5", 
                                             "http://name5.org/", "p5");
  int i = XMLToken_addAttr(token, "name1", "val1");
  i = XMLToken_addAttrWithNS(token, "name2", "val2", 
                                             "http://name1.org/", "p1");
  i = XMLToken_addAttrWithTriple(token, xt2, "val2");
  i = XMLToken_addAttr(token, "name4", "val4");

  fail_unless (XMLAttributes_getLength(XMLToken_getAttributes(token)) == 4);

  i = XMLToken_removeAttr(token, 7);

  fail_unless ( i == LIBSBML_INDEX_EXCEEDS_SIZE );

  i = XMLToken_removeAttrByName(token, "name7");

  fail_unless ( i == LIBSBML_INDEX_EXCEEDS_SIZE );

  i = XMLToken_removeAttrByNS(token, "name7", "namespaces7");

  fail_unless ( i == LIBSBML_INDEX_EXCEEDS_SIZE );

  i = XMLToken_removeAttrByTriple(token, xt1);

  fail_unless ( i == LIBSBML_INDEX_EXCEEDS_SIZE );
  fail_unless (XMLAttributes_getLength(XMLToken_getAttributes(token)) == 4);

  i = XMLToken_removeAttr(token, 3);

  fail_unless ( i == LIBSBML_OPERATION_SUCCESS );
  fail_unless (XMLAttributes_getLength(XMLToken_getAttributes(token)) == 3);

  i = XMLToken_removeAttrByName(token, "name1");

  fail_unless ( i == LIBSBML_OPERATION_SUCCESS );
  fail_unless (XMLAttributes_getLength(XMLToken_getAttributes(token)) == 2);

  i = XMLToken_removeAttrByNS(token, "name2", "http://name1.org/");

  fail_unless ( i == LIBSBML_OPERATION_SUCCESS );
  fail_unless (XMLAttributes_getLength(XMLToken_getAttributes(token)) == 1);

  i = XMLToken_removeAttrByTriple(token, xt2);

  fail_unless ( i == LIBSBML_OPERATION_SUCCESS );
  fail_unless (XMLAttributes_getLength(XMLToken_getAttributes(token)) == 0);

  /*-- teardown --*/

  XMLTriple_free(xt1);
  XMLTriple_free(xt2);
  XMLTriple_free(triple);
  XMLAttributes_free(attr);
  XMLToken_free(token);
}