Пример #1
0
END_TEST


START_TEST (test_XMLNamespaces_remove1)
{
  XMLNamespaces_add(NS, "http://test1.org/", "test1"); 
  XMLNamespaces_add(NS, "http://test2.org/", "test2");

  fail_unless( XMLNamespaces_getLength(NS) == 2 );
  
  int i = XMLNamespaces_remove(NS, 4);
  
  fail_unless (i == LIBSBML_INDEX_EXCEEDS_SIZE );
  fail_unless( XMLNamespaces_getLength(NS) == 2 );
  
  i = XMLNamespaces_removeByPrefix(NS, "test4");

  fail_unless (i == LIBSBML_INDEX_EXCEEDS_SIZE );
  fail_unless( XMLNamespaces_getLength(NS) == 2 );

  i = XMLNamespaces_remove(NS, 1);

  fail_unless (i == LIBSBML_OPERATION_SUCCESS );
  fail_unless( XMLNamespaces_getLength(NS) == 1 );

  i = XMLNamespaces_removeByPrefix(NS, "test1");

  fail_unless (i == LIBSBML_OPERATION_SUCCESS );
  fail_unless( XMLNamespaces_getLength(NS) == 0 );
}
Пример #2
0
END_TEST


START_TEST (test_XMLNamespaces_add)
{
  fail_unless( XMLNamespaces_getLength(NS) == 0 );
  fail_unless( XMLNamespaces_isEmpty(NS) == 1 );

  XMLNamespaces_add(NS, "http://test1.org/", "test1");
  fail_unless( XMLNamespaces_getLength(NS) == 1 );
  fail_unless( XMLNamespaces_isEmpty(NS) == 0 );

  XMLNamespaces_add(NS, "http://test2.org/", "test2");
  fail_unless( XMLNamespaces_getLength(NS) == 2 );
  fail_unless( XMLNamespaces_isEmpty(NS) == 0 );

  XMLNamespaces_add(NS, "http://test1.org/", "test1a");
  fail_unless( XMLNamespaces_getLength(NS) == 3 );
  fail_unless( XMLNamespaces_isEmpty(NS) == 0 );

  XMLNamespaces_add(NS, "http://test1.org/", "test1a");
  fail_unless( XMLNamespaces_getLength(NS) == 3 );
  fail_unless( XMLNamespaces_isEmpty(NS) == 0 );


  fail_if( XMLNamespaces_getIndex(NS, "http://test1.org/") == -1);
}
END_TEST


START_TEST (test_ModifierSpeciesReference_createWithNS )
{
  XMLNamespaces_t *xmlns = XMLNamespaces_create();
  XMLNamespaces_add(xmlns, "http://www.sbml.org", "testsbml");
  SBMLNamespaces_t *sbmlns = SBMLNamespaces_create(2,1);
  SBMLNamespaces_addNamespaces(sbmlns,xmlns);

  SBase_t *object = (SBase_t *) SpeciesReference_createModifierWithNS(sbmlns);

  fail_unless( SBase_getTypeCode  ((SBase_t *) object) == SBML_MODIFIER_SPECIES_REFERENCE );
  fail_unless( SBase_getMetaId    ((SBase_t *) object) == NULL );
  fail_unless( SBase_getNotes     ((SBase_t *) object) == NULL );
  fail_unless( SBase_getAnnotation((SBase_t *) object) == NULL );

  fail_unless( SBase_getLevel       ((SBase_t *) object) == 2 );
  fail_unless( SBase_getVersion     ((SBase_t *) object) == 1 );

  fail_unless( SpeciesReference_getNamespaces ((SpeciesReference_t *) object) != NULL );
  const XMLNamespaces_t *n = SpeciesReference_getNamespaces((SpeciesReference_t *) object);
  fail_unless( XMLNamespaces_getLength( n ) == 2 );

  SpeciesReference_free((SpeciesReference_t *) object);
}
END_TEST


START_TEST (test_UnitDefinition_createWithNS )
{
  XMLNamespaces_t *xmlns = XMLNamespaces_create();
  XMLNamespaces_add(xmlns, "http://www.sbml.org", "testsbml");
  SBMLNamespaces_t *sbmlns = SBMLNamespaces_create(2,1);
  SBMLNamespaces_addNamespaces(sbmlns,xmlns);

  UnitDefinition_t *object = 
    UnitDefinition_createWithNS (sbmlns);


  fail_unless( SBase_getTypeCode  ((SBase_t *) object) == SBML_UNIT_DEFINITION );
  fail_unless( SBase_getMetaId    ((SBase_t *) object) == NULL );
  fail_unless( SBase_getNotes     ((SBase_t *) object) == NULL );
  fail_unless( SBase_getAnnotation((SBase_t *) object) == NULL );

  fail_unless( SBase_getLevel       ((SBase_t *) object) == 2 );
  fail_unless( SBase_getVersion     ((SBase_t *) object) == 1 );

  fail_unless( UnitDefinition_getNamespaces     (object) != NULL );
  fail_unless( XMLNamespaces_getLength(
                        UnitDefinition_getNamespaces(object)) == 2 );

  UnitDefinition_free(object);
}
Пример #5
0
END_TEST


START_TEST (test_AlgebraicRule_createWithNS )
{
  XMLNamespaces_t *xmlns = XMLNamespaces_create();
  XMLNamespaces_add(xmlns, "http://www.sbml.org", "testsbml");
  SBMLNamespaces_t *sbmlns = SBMLNamespaces_create(2,3);
  SBMLNamespaces_addNamespaces(sbmlns,xmlns);

  AlgebraicRule_t *r = 
    AlgebraicRule_createWithNS(sbmlns);


  fail_unless( SBase_getTypeCode  ((SBase_t *) r) == SBML_ALGEBRAIC_RULE );
  fail_unless( SBase_getMetaId    ((SBase_t *) r) == NULL );
  fail_unless( SBase_getNotes     ((SBase_t *) r) == NULL );
  fail_unless( SBase_getAnnotation((SBase_t *) r) == NULL );

  fail_unless( SBase_getLevel       ((SBase_t *) r) == 2 );
  fail_unless( SBase_getVersion     ((SBase_t *) r) == 3 );

  fail_unless( Rule_getNamespaces     ((Rule_t*)(r)) != NULL );
  fail_unless( XMLNamespaces_getLength(Rule_getNamespaces((Rule_t*)(r))) == 2 );


  Rule_free((Rule_t*)(r));
  XMLNamespaces_free(xmlns);
  SBMLNamespaces_free(sbmlns);
}
Пример #6
0
END_TEST


START_TEST (test_Constraint_createWithNS )
{
  XMLNamespaces_t *xmlns = XMLNamespaces_create();
  XMLNamespaces_add(xmlns, "http://www.sbml.org", "testsbml");
  SBMLNamespaces_t *sbmlns = SBMLNamespaces_create(2,2);
  SBMLNamespaces_addNamespaces(sbmlns,xmlns);

  Constraint_t *object = 
    Constraint_createWithNS (sbmlns);


  fail_unless( SBase_getTypeCode  ((SBase_t *) object) == SBML_CONSTRAINT );
  fail_unless( SBase_getMetaId    ((SBase_t *) object) == NULL );
  fail_unless( SBase_getNotes     ((SBase_t *) object) == NULL );
  fail_unless( SBase_getAnnotation((SBase_t *) object) == NULL );

  fail_unless( SBase_getLevel       ((SBase_t *) object) == 2 );
  fail_unless( SBase_getVersion     ((SBase_t *) object) == 2 );

  fail_unless( Constraint_getNamespaces     (object) != NULL );
  fail_unless( XMLNamespaces_getLength(Constraint_getNamespaces(object)) == 2 );

  Constraint_free(object);
}
Пример #7
0
END_TEST


START_TEST (test_Species_createWithNS )
{
  XMLNamespaces_t *xmlns = XMLNamespaces_create();
  XMLNamespaces_add(xmlns, "http://www.sbml.org", "testsbml");
  SBMLNamespaces_t *sbmlns = SBMLNamespaces_create(2,1);
  SBMLNamespaces_addNamespaces(sbmlns,xmlns);

  Species_t *object = 
    Species_createWithNS (sbmlns);


  fail_unless( SBase_getTypeCode  ((SBase_t *) object) == SBML_SPECIES );
  fail_unless( SBase_getMetaId    ((SBase_t *) object) == NULL );
  fail_unless( SBase_getNotes     ((SBase_t *) object) == NULL );
  fail_unless( SBase_getAnnotation((SBase_t *) object) == NULL );

  fail_unless( SBase_getLevel       ((SBase_t *) object) == 2 );
  fail_unless( SBase_getVersion     ((SBase_t *) object) == 1 );

  fail_unless( Species_getNamespaces     (object) != NULL );
  fail_unless( XMLNamespaces_getLength(Species_getNamespaces(object)) == 2 );

  Species_free(object);
  XMLNamespaces_free(xmlns);
  SBMLNamespaces_free(sbmlns);
}
END_TEST


START_TEST (test_EventAssignment_createWithNS )
{
  XMLNamespaces_t *xmlns = XMLNamespaces_create();
  XMLNamespaces_add(xmlns, "http://www.sbml.org", "testsbml");
  SBMLNamespaces_t *sbmlns = SBMLNamespaces_create(2,1);
  SBMLNamespaces_addNamespaces(sbmlns,xmlns);

  EventAssignment_t *object = 
    EventAssignment_createWithNS (sbmlns);


  fail_unless( SBase_getTypeCode  ((SBase_t *) object) == SBML_EVENT_ASSIGNMENT );
  fail_unless( SBase_getMetaId    ((SBase_t *) object) == NULL );
  fail_unless( SBase_getNotes     ((SBase_t *) object) == NULL );
  fail_unless( SBase_getAnnotation((SBase_t *) object) == NULL );

  fail_unless( SBase_getLevel       ((SBase_t *) object) == 2 );
  fail_unless( SBase_getVersion     ((SBase_t *) object) == 1 );

  fail_unless( EventAssignment_getNamespaces     (object) != NULL );
  fail_unless( XMLNamespaces_getLength(
                        EventAssignment_getNamespaces(object)) == 2 );

  EventAssignment_free(object);
  XMLNamespaces_free(xmlns);
  SBMLNamespaces_free(sbmlns);
}
Пример #9
0
END_TEST


START_TEST (test_Priority_createWithNS )
{
  XMLNamespaces_t *xmlns = XMLNamespaces_create();
  XMLNamespaces_add(xmlns, "http://www.sbml.org", "testsbml");
  SBMLNamespaces_t *sbmlns = SBMLNamespaces_create(3,1);
  SBMLNamespaces_addNamespaces(sbmlns,xmlns);

  Priority_t *object = 
    Priority_createWithNS (sbmlns);


  fail_unless( SBase_getTypeCode  ((SBase_t *) object) == SBML_PRIORITY );
  fail_unless( SBase_getMetaId    ((SBase_t *) object) == NULL );
  fail_unless( SBase_getNotes     ((SBase_t *) object) == NULL );
  fail_unless( SBase_getAnnotation((SBase_t *) object) == NULL );

  fail_unless( SBase_getLevel       ((SBase_t *) object) == 3 );
  fail_unless( SBase_getVersion     ((SBase_t *) object) == 1 );

  fail_unless( Priority_getNamespaces     (object) != NULL );
  fail_unless( XMLNamespaces_getLength(Priority_getNamespaces(object)) == 2 );

  Priority_free(object);
}
Пример #10
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);
}
Пример #11
0
END_TEST


START_TEST (test_Compartment_createWithNS )
{
  XMLNamespaces_t *xmlns = XMLNamespaces_create();
  XMLNamespaces_add(xmlns, "http://www.sbml.org", "testsbml");
  SBMLNamespaces_t *sbmlns = SBMLNamespaces_create(2,1);
  SBMLNamespaces_addNamespaces(sbmlns,xmlns);

  Compartment_t *c = 
    Compartment_createWithNS (sbmlns);


  fail_unless( SBase_getTypeCode  ((SBase_t *) c) == SBML_COMPARTMENT );
  fail_unless( SBase_getMetaId    ((SBase_t *) c) == NULL );
  fail_unless( SBase_getNotes     ((SBase_t *) c) == NULL );
  fail_unless( SBase_getAnnotation((SBase_t *) c) == NULL );

  fail_unless( SBase_getLevel       ((SBase_t *) c) == 2 );
  fail_unless( SBase_getVersion     ((SBase_t *) c) == 1 );

  fail_unless( Compartment_getNamespaces     (c) != NULL );
  fail_unless( XMLNamespaces_getLength(Compartment_getNamespaces(c)) == 2 );


  fail_unless( Compartment_getName(c)              == NULL );
  fail_unless( Compartment_getSpatialDimensions(c) == 3    );
  fail_unless( Compartment_getConstant(c) == 1   );

  Compartment_free(c);
  XMLNamespaces_free(xmlns);
  SBMLNamespaces_free(sbmlns);
}
Пример #12
0
END_TEST


START_TEST (test_XMLNamespaces_get)
{
  XMLNamespaces_add(NS, "http://test1.org/", "test1");    /* index 0 */
  XMLNamespaces_add(NS, "http://test2.org/", "test2");    /* index 1 */
  XMLNamespaces_add(NS, "http://test3.org/", "test3");    /* index 2 */
  XMLNamespaces_add(NS, "http://test4.org/", "test4");    /* index 3 */
  XMLNamespaces_add(NS, "http://test5.org/", "test5");    /* index 4 */
  XMLNamespaces_add(NS, "http://test6.org/", "test6");    /* index 5 */
  XMLNamespaces_add(NS, "http://test7.org/", "test7");    /* index 6 */
  XMLNamespaces_add(NS, "http://test8.org/", "test8");    /* index 7 */
  XMLNamespaces_add(NS, "http://test9.org/", "test9");    /* index 8 */

  fail_unless( XMLNamespaces_getLength(NS) == 9 );

  fail_unless( XMLNamespaces_getIndex(NS, "http://test1.org/") == 0 );
  fail_unless( strcmp(XMLNamespaces_getPrefix(NS, 1), "test2") == 0 );
  fail_unless( strcmp(XMLNamespaces_getPrefixByURI(NS, "http://test1.org/"),
		      "test1") == 0 );
  fail_unless( strcmp(XMLNamespaces_getURI(NS, 1), "http://test2.org/") == 0 );
  fail_unless( strcmp(XMLNamespaces_getURIByPrefix(NS, "test2"),
		      "http://test2.org/") == 0 );

  fail_unless( XMLNamespaces_getIndex(NS, "http://test1.org/") ==  0 );
  fail_unless( XMLNamespaces_getIndex(NS, "http://test2.org/") ==  1 );
  fail_unless( XMLNamespaces_getIndex(NS, "http://test5.org/") ==  4 );
  fail_unless( XMLNamespaces_getIndex(NS, "http://test9.org/") ==  8 );
  fail_unless( XMLNamespaces_getIndex(NS, "http://testX.org/") == -1 );

  fail_unless( XMLNamespaces_hasURI(NS, "http://test1.org/") !=  0 );
  fail_unless( XMLNamespaces_hasURI(NS, "http://test2.org/") !=  0 );
  fail_unless( XMLNamespaces_hasURI(NS, "http://test5.org/") !=  0 );
  fail_unless( XMLNamespaces_hasURI(NS, "http://test9.org/") !=  0 );
  fail_unless( XMLNamespaces_hasURI(NS, "http://testX.org/") ==  0 );

  fail_unless( XMLNamespaces_getIndexByPrefix(NS, "test1") ==  0 );
  fail_unless( XMLNamespaces_getIndexByPrefix(NS, "test5") ==  4 );
  fail_unless( XMLNamespaces_getIndexByPrefix(NS, "test9") ==  8 );
  fail_unless( XMLNamespaces_getIndexByPrefix(NS, "testX") == -1 );

  fail_unless( XMLNamespaces_hasPrefix(NS, "test1") !=  0 );
  fail_unless( XMLNamespaces_hasPrefix(NS, "test5") !=  0 );
  fail_unless( XMLNamespaces_hasPrefix(NS, "test9") !=  0 );
  fail_unless( XMLNamespaces_hasPrefix(NS, "testX") ==  0 );

  fail_unless( XMLNamespaces_hasNS(NS, "http://test1.org/", "test1") !=  0 );
  fail_unless( XMLNamespaces_hasNS(NS, "http://test5.org/", "test5") !=  0 );
  fail_unless( XMLNamespaces_hasNS(NS, "http://test9.org/", "test9") !=  0 );
  fail_unless( XMLNamespaces_hasNS(NS, "http://testX.org/", "testX") ==  0 );
}
Пример #13
0
END_TEST


START_TEST (test_XMLNamespaces_remove)
{
  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 );
  fail_unless( XMLNamespaces_getNumNamespaces(NS) == 5 );
  XMLNamespaces_remove(NS, 4);
  fail_unless( XMLNamespaces_getLength(NS) == 4 );
  XMLNamespaces_remove(NS, 3);
  fail_unless( XMLNamespaces_getLength(NS) == 3 );
  XMLNamespaces_remove(NS, 2);
  fail_unless( XMLNamespaces_getLength(NS) == 2 );
  XMLNamespaces_remove(NS, 1);
  fail_unless( XMLNamespaces_getLength(NS) == 1 );
  XMLNamespaces_remove(NS, 0);
  fail_unless( XMLNamespaces_getLength(NS) == 0 );
  fail_unless( XMLNamespaces_getNumNamespaces(NS) == 0 );

  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 );
  fail_unless( XMLNamespaces_getNumNamespaces(NS) == 5 );
  XMLNamespaces_remove(NS, 0);
  fail_unless( XMLNamespaces_getLength(NS) == 4 );
  XMLNamespaces_remove(NS, 0);
  fail_unless( XMLNamespaces_getLength(NS) == 3 );
  XMLNamespaces_remove(NS, 0);
  fail_unless( XMLNamespaces_getLength(NS) == 2 );
  fail_unless( XMLNamespaces_getNumNamespaces(NS) == 2 );
  XMLNamespaces_remove(NS, 0);
  fail_unless( XMLNamespaces_getLength(NS) == 1 );
  XMLNamespaces_remove(NS, 0);
  fail_unless( XMLNamespaces_getLength(NS) == 0 );
  fail_unless( XMLNamespaces_getNumNamespaces(NS) == 0 );

}
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 );
}
Пример #15
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_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);
}
Пример #17
0
END_TEST


START_TEST (test_L3_Species_createWithNS )
{
  XMLNamespaces_t *xmlns = XMLNamespaces_create();
  XMLNamespaces_add(xmlns, "http://www.sbml.org", "testsbml");
  SBMLNamespaces_t *sbmlns = SBMLNamespaces_create(3,1);
  SBMLNamespaces_addNamespaces(sbmlns,xmlns);

  Species_t *s = 
    Species_createWithNS (sbmlns);


  fail_unless( SBase_getTypeCode  ((SBase_t *) s) == SBML_SPECIES );
  fail_unless( SBase_getMetaId    ((SBase_t *) s) == NULL );
  fail_unless( SBase_getNotes     ((SBase_t *) s) == NULL );
  fail_unless( SBase_getAnnotation((SBase_t *) s) == NULL );

  fail_unless( SBase_getLevel       ((SBase_t *) s) == 3 );
  fail_unless( SBase_getVersion     ((SBase_t *) s) == 1 );

  fail_unless( Species_getNamespaces     (s) != NULL );
  fail_unless( XMLNamespaces_getLength(Species_getNamespaces(s)) == 2 );


  fail_unless( Species_getId     (s) == NULL );
  fail_unless( Species_getName   (s) == NULL );
  fail_unless( Species_getCompartment  (s) == NULL );
  fail_unless( util_isNaN(Species_getInitialAmount (s)) );
  fail_unless( util_isNaN(Species_getInitialConcentration (s)) );
  fail_unless( Species_getSubstanceUnits  (s) == NULL );
  fail_unless( Species_getHasOnlySubstanceUnits(s) == 0   );
  fail_unless( Species_getBoundaryCondition(s) == 0   );
  fail_unless( Species_getConstant(s) == 0   );
  fail_unless( Species_getConversionFactor  (s) == NULL );

  fail_unless( !Species_isSetId     (s) );
  fail_unless( !Species_isSetName   (s) );
  fail_unless( !Species_isSetCompartment (s) );
  fail_unless( !Species_isSetInitialAmount (s) );
  fail_unless( !Species_isSetInitialConcentration (s) );
  fail_unless( !Species_isSetSubstanceUnits  (s) );
  fail_unless( !Species_isSetHasOnlySubstanceUnits(s)   );
  fail_unless( !Species_isSetBoundaryCondition(s)   );
  fail_unless( !Species_isSetConstant(s)   );
  fail_unless( !Species_isSetConversionFactor  (s) );

  Species_free(s);
  XMLNamespaces_free(xmlns);
  SBMLNamespaces_free(sbmlns);
}
Пример #18
0
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);
}
Пример #19
0
END_TEST


START_TEST (test_XMLNamespaces_add1)
{
  fail_unless( XMLNamespaces_getLength(NS) == 0 );
  fail_unless( XMLNamespaces_isEmpty(NS) == 1 );

  int i = XMLNamespaces_add(NS, "http://test1.org/", "test1");

  fail_unless( i == LIBSBML_OPERATION_SUCCESS);
  fail_unless( XMLNamespaces_getLength(NS) == 1 );
  fail_unless( XMLNamespaces_isEmpty(NS) == 0 );
}
Пример #20
0
END_TEST


START_TEST (test_L3_Model_createWithNS )
{
  XMLNamespaces_t *xmlns = XMLNamespaces_create();
  XMLNamespaces_add(xmlns, "http://www.sbml.org", "testsbml");
  SBMLNamespaces_t *sbmlns = SBMLNamespaces_create(3,1);
  SBMLNamespaces_addNamespaces(sbmlns,xmlns);

  Model_t *m = 
    Model_createWithNS (sbmlns);


  fail_unless( SBase_getTypeCode  ((SBase_t *) m) == SBML_MODEL );
  fail_unless( SBase_getMetaId    ((SBase_t *) m) == NULL );
  fail_unless( SBase_getNotes     ((SBase_t *) m) == NULL );
  fail_unless( SBase_getAnnotation((SBase_t *) m) == NULL );

  fail_unless( SBase_getLevel       ((SBase_t *) m) == 3 );
  fail_unless( SBase_getVersion     ((SBase_t *) m) == 1 );

  fail_unless( Model_getNamespaces     (m) != NULL );
  fail_unless( XMLNamespaces_getLength(Model_getNamespaces(m)) == 2 );


  fail_unless( Model_getId     (m) == NULL );
  fail_unless( Model_getName   (m) == NULL );
  fail_unless( Model_getSubstanceUnits(m) == NULL );
  fail_unless( Model_getTimeUnits(m) == NULL );
  fail_unless( Model_getVolumeUnits(m) == NULL );
  fail_unless( Model_getAreaUnits(m) == NULL );
  fail_unless( Model_getLengthUnits(m) == NULL );
  fail_unless( Model_getConversionFactor(m) == NULL );

  fail_unless( !Model_isSetId     (m) );
  fail_unless( !Model_isSetName   (m) );
  fail_unless( !Model_isSetSubstanceUnits(m) );
  fail_unless( !Model_isSetTimeUnits(m) );
  fail_unless( !Model_isSetVolumeUnits(m) );
  fail_unless( !Model_isSetAreaUnits(m) );
  fail_unless( !Model_isSetLengthUnits(m) );
  fail_unless( !Model_isSetConversionFactor(m) );

  Model_free(m);
  XMLNamespaces_free(xmlns);
  SBMLNamespaces_free(sbmlns);
}
END_TEST


START_TEST (test_L3_SpeciesReference_createWithNS )
{
  XMLNamespaces_t *xmlns = XMLNamespaces_create();
  XMLNamespaces_add(xmlns, "http://www.sbml.org", "testsbml");
  SBMLNamespaces_t *sbmlns = SBMLNamespaces_create(3,1);
  SBMLNamespaces_addNamespaces(sbmlns,xmlns);

  SpeciesReference_t *sr = 
    SpeciesReference_createWithNS (sbmlns);


  fail_unless( SBase_getTypeCode  ((SBase_t *) sr) == SBML_SPECIES_REFERENCE );
  fail_unless( SBase_getMetaId    ((SBase_t *) sr) == NULL );
  fail_unless( SBase_getNotes     ((SBase_t *) sr) == NULL );
  fail_unless( SBase_getAnnotation((SBase_t *) sr) == NULL );

  fail_unless( SBase_getLevel       ((SBase_t *) sr) == 3 );
  fail_unless( SBase_getVersion     ((SBase_t *) sr) == 1 );

  fail_unless( SpeciesReference_getNamespaces     (sr) != NULL );
  fail_unless( XMLNamespaces_getLength(SpeciesReference_getNamespaces(sr)) == 2 );


  fail_unless( SpeciesReference_getId     (sr) == NULL );
  fail_unless( SpeciesReference_getName   (sr) == NULL );
  fail_unless( SpeciesReference_getSpecies  (sr) == NULL );
  fail_unless( util_isNaN(SpeciesReference_getStoichiometry (sr)) );
  fail_unless( SpeciesReference_getConstant(sr) == 0   );

  fail_unless( !SpeciesReference_isSetId     (sr) );
  fail_unless( !SpeciesReference_isSetName   (sr) );
  fail_unless( !SpeciesReference_isSetSpecies (sr) );
  fail_unless( !SpeciesReference_isSetStoichiometry (sr) );
  fail_unless( !SpeciesReference_isSetConstant(sr)   );

  SpeciesReference_free(sr);
  XMLNamespaces_free(xmlns);
  SBMLNamespaces_free(sbmlns);
}
Пример #22
0
END_TEST


START_TEST (test_L3_Parameter_createWithNS )
{
  XMLNamespaces_t *xmlns = XMLNamespaces_create();
  XMLNamespaces_add(xmlns, "http://www.sbml.org", "testsbml");
  SBMLNamespaces_t *sbmlns = SBMLNamespaces_create(3,1);
  SBMLNamespaces_addNamespaces(sbmlns,xmlns);

  Parameter_t *p = 
    Parameter_createWithNS (sbmlns);


  fail_unless( SBase_getTypeCode  ((SBase_t *) p) == SBML_PARAMETER );
  fail_unless( SBase_getMetaId    ((SBase_t *) p) == NULL );
  fail_unless( SBase_getNotes     ((SBase_t *) p) == NULL );
  fail_unless( SBase_getAnnotation((SBase_t *) p) == NULL );

  fail_unless( SBase_getLevel       ((SBase_t *) p) == 3 );
  fail_unless( SBase_getVersion     ((SBase_t *) p) == 1 );

  fail_unless( Parameter_getNamespaces     (p) != NULL );
  fail_unless( XMLNamespaces_getLength(Parameter_getNamespaces(p)) == 2 );


  fail_unless( Parameter_getId     (p) == NULL );
  fail_unless( Parameter_getName   (p) == NULL );
  fail_unless( Parameter_getUnits  (p) == NULL );
  fail_unless( isnan(Parameter_getValue(p)));
  fail_unless( Parameter_getConstant(p) == 1   );

  fail_unless( !Parameter_isSetId     (p) );
  fail_unless( !Parameter_isSetName   (p) );
  fail_unless( !Parameter_isSetValue (p) );
  fail_unless( !Parameter_isSetUnits  (p) );
  fail_unless( !Parameter_isSetConstant(p) );

  Parameter_free(p);
}
Пример #23
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);
}
Пример #24
0
END_TEST


START_TEST (test_L3_Event_createWithNS )
{
  XMLNamespaces_t *xmlns = XMLNamespaces_create();
  XMLNamespaces_add(xmlns, "http://www.sbml.org", "testsbml");
  SBMLNamespaces_t *sbmlns = SBMLNamespaces_create(3,1);
  SBMLNamespaces_addNamespaces(sbmlns,xmlns);

  Event_t *e = 
    Event_createWithNS (sbmlns);


  fail_unless( SBase_getTypeCode  ((SBase_t *) e) == SBML_EVENT );
  fail_unless( SBase_getMetaId    ((SBase_t *) e) == NULL );
  fail_unless( SBase_getNotes     ((SBase_t *) e) == NULL );
  fail_unless( SBase_getAnnotation((SBase_t *) e) == NULL );

  fail_unless( SBase_getLevel       ((SBase_t *) e) == 3 );
  fail_unless( SBase_getVersion     ((SBase_t *) e) == 1 );

  fail_unless( Event_getNamespaces     (e) != NULL );
  fail_unless( XMLNamespaces_getLength(Event_getNamespaces(e)) == 2 );


  fail_unless( Event_getId     (e) == NULL );
  fail_unless( Event_getName   (e) == NULL );
  fail_unless( Event_getUseValuesFromTriggerTime(e) == 1   );

  fail_unless( !Event_isSetId     (e) );
  fail_unless( !Event_isSetName   (e) );
  fail_unless( !Event_isSetUseValuesFromTriggerTime(e) );

  Event_free(e);
  XMLNamespaces_free(xmlns);
  SBMLNamespaces_free(sbmlns);
}
Пример #25
0
END_TEST


START_TEST (test_L3_Unit_createWithNS )
{
  XMLNamespaces_t *xmlns = XMLNamespaces_create();
  XMLNamespaces_add(xmlns, "http://www.sbml.org", "testsbml");
  SBMLNamespaces_t *sbmlns = SBMLNamespaces_create(3,1);
  SBMLNamespaces_addNamespaces(sbmlns,xmlns);

  Unit_t *u = 
    Unit_createWithNS (sbmlns);


  fail_unless( SBase_getTypeCode  ((SBase_t *) u) == SBML_UNIT );
  fail_unless( SBase_getMetaId    ((SBase_t *) u) == NULL );
  fail_unless( SBase_getNotes     ((SBase_t *) u) == NULL );
  fail_unless( SBase_getAnnotation((SBase_t *) u) == NULL );

  fail_unless( SBase_getLevel       ((SBase_t *) u) == 3 );
  fail_unless( SBase_getVersion     ((SBase_t *) u) == 1 );

  fail_unless( Unit_getNamespaces     (u) != NULL );
  fail_unless( XMLNamespaces_getLength(Unit_getNamespaces(u)) == 2 );


  fail_unless( Unit_getKind     (u) == UNIT_KIND_INVALID );
  fail_unless( isnan(Unit_getExponentAsDouble (u)) );
  fail_unless( isnan(Unit_getMultiplier (u)) );
//  fail_unless( isnan((double)(Unit_getScale (u))) );

  fail_unless( !Unit_isSetKind     (u) );
  fail_unless( !Unit_isSetExponent (u) );
  fail_unless( !Unit_isSetMultiplier (u) );
  fail_unless( !Unit_isSetScale (u) );

  Unit_free(u);
}
Пример #26
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);
}
Пример #27
0
END_TEST


//START_TEST (test_RateRule_createWithFormula)
//{
//  const ASTNode_t *math;
//  char *formula;
//
//  Rule_t *ar = Rule_createRateWithVariableAndFormula("s", "1 + 1");
//
//
//  fail_unless( SBase_getTypeCode  ((SBase_t *) ar) == SBML_RATE_RULE );
//  fail_unless( SBase_getMetaId    ((SBase_t *) ar) == NULL );
//  fail_unless( !strcmp(Rule_getVariable(ar), "s") );
//
//  math = Rule_getMath((Rule_t *) ar);
//  fail_unless(math != NULL);
//
//  formula = SBML_formulaToString(math);
//  fail_unless( formula != NULL );
//  fail_unless( !strcmp(formula, "1 + 1") );
//
//  fail_unless( !strcmp(Rule_getFormula((Rule_t *) ar), formula) );
//
//  Rule_free(ar);
//  safe_free(formula);
//}
//END_TEST


//START_TEST (test_RateRule_createWithMath)
//{
//  ASTNode_t       *math = SBML_parseFormula("1 + 1");
//
//  Rule_t *ar = Rule_createRateWithVariableAndMath("s", math);
//
//
//  fail_unless( SBase_getTypeCode  ((SBase_t *) ar) == SBML_RATE_RULE );
//  fail_unless( SBase_getMetaId    ((SBase_t *) ar) == NULL );
//  fail_unless( !strcmp(Rule_getVariable(ar), "s") );
//  fail_unless( !strcmp(Rule_getFormula((Rule_t *) ar), "1 + 1") );
//  fail_unless( Rule_getMath((Rule_t *) ar) != math );
//
//  Rule_free(ar);
//}
//END_TEST


START_TEST (test_RateRule_createWithNS )
{
  XMLNamespaces_t *xmlns = XMLNamespaces_create();
  XMLNamespaces_add(xmlns, "http://www.sbml.org", "testsbml");
  SBMLNamespaces_t *sbmlns = SBMLNamespaces_create(2,1);
  SBMLNamespaces_addNamespaces(sbmlns,xmlns);

  Rule_t *object = 
    Rule_createRateWithNS(sbmlns);


  fail_unless( SBase_getTypeCode  ((SBase_t *) object) == SBML_RATE_RULE );
  fail_unless( SBase_getMetaId    ((SBase_t *) object) == NULL );
  fail_unless( SBase_getNotes     ((SBase_t *) object) == NULL );
  fail_unless( SBase_getAnnotation((SBase_t *) object) == NULL );

  fail_unless( SBase_getLevel       ((SBase_t *) object) == 2 );
  fail_unless( SBase_getVersion     ((SBase_t *) object) == 1 );

  fail_unless( Rule_getNamespaces     (object) != NULL );
  fail_unless( XMLNamespaces_getLength(Rule_getNamespaces(object)) == 2 );

  Rule_free(object);
}
Пример #28
0
LIBSBML_CPP_NAMESPACE_USE


int main(int argc,char** argv)
{
  int retval = 0;
  XMLNamespaces_t * comp;
  SBMLNamespaces_t * sbmlns;
  SBMLDocument_t * doc;
  Compartment_t * c;
  Species_t * s1;
  Species_t * s2;
  Species_t * s3;
  Species_t * s4;
  Reaction_t * r1;
  Reaction_t * r2;
  SpeciesReference_t *sr1;
  SpeciesReference_t *sr2;
  SpeciesReference_t *sr3;
  SpeciesReference_t *sr4;
  SpeciesReference_t *sr5;
  SpeciesReference_t *sr6;
  Model_t * model;
  CompSBMLDocumentPlugin_t * docPlug;
  CompModelPlugin_t *modelPlug;
  Submodel_t * sub1;
  Submodel_t * sub2;
  ModelDefinition_t * modDef;

  /* get comp registry entry */
  SBMLExtension_t *sbmlext = SBMLExtensionRegistry_getExtension("comp");

  /* create the sbml namespaces object with comp */
  comp = XMLNamespaces_create();
  XMLNamespaces_add(comp, SBMLExtension_getURI(sbmlext, 3, 1, 1), "comp");
  
  sbmlns = SBMLNamespaces_create(3, 1);
  SBMLNamespaces_addNamespaces(sbmlns, comp);

  /* create the document */
  doc = SBMLDocument_createWithSBMLNamespaces(sbmlns);

  /* set the comp reqd attribute to true */
  docPlug = (CompSBMLDocumentPlugin_t * )(SBase_getPlugin((SBase_t*)(doc), "comp"));
  SBMLDocumentPlugin_setRequired((SBMLDocumentPlugin_t*)(docPlug), 1);


  /* create the submodel */
  modDef = CompSBMLDocumentPlugin_createModelDefinition(docPlug);

  Model_setId((Model_t*)(modDef), "enzyme");
  Model_setName((Model_t*)(modDef), "enzyme");

  c = Model_createCompartment((Model_t*)(modDef));
  Compartment_setId(c, "comp");
  Compartment_setConstant(c, 1);
  Compartment_setSize(c, 1.0);
  Compartment_setSpatialDimensions(c, 3);

  s1 = Model_createSpecies((Model_t*)(modDef));
  Species_setId(s1, "S");
  Species_setCompartment(s1, "comp");
  Species_setHasOnlySubstanceUnits(s1, 0);
  Species_setBoundaryCondition(s1, 0);
  Species_setConstant(s1, 0);
  
  s2 = Model_createSpecies((Model_t*)(modDef));
  Species_setId(s2, "E");
  Species_setCompartment(s2, "comp");
  Species_setHasOnlySubstanceUnits(s2, 0);
  Species_setBoundaryCondition(s2, 0);
  Species_setConstant(s2, 0);
  
  s3 = Model_createSpecies((Model_t*)(modDef));
  Species_setId(s3, "D");
  Species_setCompartment(s3, "comp");
  Species_setHasOnlySubstanceUnits(s3, 0);
  Species_setBoundaryCondition(s3, 0);
  Species_setConstant(s3, 0);

  s4 = Model_createSpecies((Model_t*)(modDef));
  Species_setId(s4, "ES");
  Species_setCompartment(s4, "comp");
  Species_setHasOnlySubstanceUnits(s4, 0);
  Species_setBoundaryCondition(s4, 0);
  Species_setConstant(s4, 0);

  r1 = Model_createReaction((Model_t*)(modDef));
  Reaction_setId(r1, "J0");
  Reaction_setReversible(r1, 1);
  Reaction_setFast(r1, 0);

  sr1 = Reaction_createReactant(r1);
  SpeciesReference_setSpecies(sr1, "S");
  SpeciesReference_setStoichiometry(sr1, 1.0);
  SpeciesReference_setConstant(sr1, 1);


  sr2 = Reaction_createReactant(r1);
  SpeciesReference_setSpecies(sr2, "E");
  SpeciesReference_setStoichiometry(sr2, 1.0);
  SpeciesReference_setConstant(sr2, 1);

  sr3 = Reaction_createProduct(r1);
  SpeciesReference_setSpecies(sr3, "ES");
  SpeciesReference_setStoichiometry(sr3, 1.0);
  SpeciesReference_setConstant(sr3, 1);

  r2 = Model_createReaction((Model_t*)(modDef));
  Reaction_setId(r2, "J1");
  Reaction_setReversible(r2, 1);
  Reaction_setFast(r2, 0);

  sr4 = Reaction_createProduct(r2);
  SpeciesReference_setSpecies(sr4, "E");
  SpeciesReference_setStoichiometry(sr4, 1.0);
  SpeciesReference_setConstant(sr4, 1);

  sr5 = Reaction_createReactant(r2);
  SpeciesReference_setSpecies(sr5, "ES");
  SpeciesReference_setStoichiometry(sr5, 1.0);
  SpeciesReference_setConstant(sr5, 1);

  sr6 = Reaction_createProduct(r2);
  SpeciesReference_setSpecies(sr6, "D");
  SpeciesReference_setStoichiometry(sr6, 1.0);
  SpeciesReference_setConstant(sr6, 1);

  /* create the model */
  model = SBMLDocument_createModel(doc);
  Model_setId(model, "aggregate");

  /* add the submodels*/
  modelPlug = (CompModelPlugin_t*)(SBase_getPlugin((SBase_t *)(model), "comp"));

  sub1 = CompModelPlugin_createSubmodel(modelPlug);
  Submodel_setId(sub1, "submod1");
  Submodel_setModelRef(sub1, "enzyme");


  sub2 = CompModelPlugin_createSubmodel(modelPlug);
  Submodel_setId(sub2, "submod2");
  Submodel_setModelRef(sub2, "enzyme");

  /* write the file */
  writeSBMLToFile(doc, "enzyme_model.xml");

  return retval;
}
Пример #29
0
END_TEST


START_TEST (test_XMLNamespaces_remove_by_prefix)
{
  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 );
  XMLNamespaces_removeByPrefix(NS, "test1");
  fail_unless( XMLNamespaces_getLength(NS) == 4 );
  XMLNamespaces_removeByPrefix(NS, "test2");
  fail_unless( XMLNamespaces_getLength(NS) == 3 );
  XMLNamespaces_removeByPrefix(NS, "test3");
  fail_unless( XMLNamespaces_getLength(NS) == 2 );
  XMLNamespaces_removeByPrefix(NS, "test4");
  fail_unless( XMLNamespaces_getLength(NS) == 1 );
  XMLNamespaces_removeByPrefix(NS, "test5");
  fail_unless( XMLNamespaces_getLength(NS) == 0 );

  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 );
  XMLNamespaces_removeByPrefix(NS, "test5");
  fail_unless( XMLNamespaces_getLength(NS) == 4 );
  XMLNamespaces_removeByPrefix(NS, "test4");
  fail_unless( XMLNamespaces_getLength(NS) == 3 );
  XMLNamespaces_removeByPrefix(NS, "test3");
  fail_unless( XMLNamespaces_getLength(NS) == 2 );
  XMLNamespaces_removeByPrefix(NS, "test2");
  fail_unless( XMLNamespaces_getLength(NS) == 1 );
  XMLNamespaces_removeByPrefix(NS, "test1");
  fail_unless( XMLNamespaces_getLength(NS) == 0 );

  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 );
  XMLNamespaces_removeByPrefix(NS, "test3");
  fail_unless( XMLNamespaces_getLength(NS) == 4 );
  XMLNamespaces_removeByPrefix(NS, "test1");
  fail_unless( XMLNamespaces_getLength(NS) == 3 );
  XMLNamespaces_removeByPrefix(NS, "test4");
  fail_unless( XMLNamespaces_getLength(NS) == 2 );
  XMLNamespaces_removeByPrefix(NS, "test5");
  fail_unless( XMLNamespaces_getLength(NS) == 1 );
  XMLNamespaces_removeByPrefix(NS, "test2");
  fail_unless( XMLNamespaces_getLength(NS) == 0 );

}
Пример #30
0
int main(int argc,char** argv)
{
  int retval = 0;
  XMLNamespaces_t * groups;
  SBMLNamespaces_t * sbmlns;
  SBMLDocument_t * doc;
  Compartment_t * compartment;
  Species_t * species;
  Model_t * model;
  SBMLDocumentPlugin_t * docPlug;
  SBasePlugin_t * modelPlug;
  Group_t * group;
  Member_t * member;

  /* get groups registry entry */
  SBMLExtension_t *sbmlext = SBMLExtensionRegistry_getExtension("groups");

  /* create the sbml namespaces object with groups */
  groups = XMLNamespaces_create();
  XMLNamespaces_add(groups, SBMLExtension_getURI(sbmlext, 3, 1, 1), "groups");
  
  sbmlns = SBMLNamespaces_create(3, 1);
  SBMLNamespaces_addNamespaces(sbmlns, groups);

  /* create the document */
  doc = SBMLDocument_createWithSBMLNamespaces(sbmlns);

  /* set the groups reqd attribute to false */
  docPlug = (SBMLDocumentPlugin_t*)(SBase_getPlugin((SBase_t*)(doc), "groups"));
  SBMLDocumentPlugin_setRequired(docPlug, 0);

  // create the Model

  model = SBMLDocument_createModel(doc);

  // create the Compartment

  compartment = Model_createCompartment(model);
  Compartment_setId(compartment, "cytosol");
  Compartment_setConstant(compartment, 1);
  Compartment_setSize(compartment, 1);

  compartment = Model_createCompartment(model);
  Compartment_setId(compartment, "mitochon");
  Compartment_setConstant(compartment, 1);
  Compartment_setSize(compartment, 1);

  // create the Species

  species = Model_createSpecies(model);
  Species_setId(species, "ATPc");
  Species_setCompartment(species, "cytosol");
  Species_setBoundaryCondition(species, 0);
  Species_setConstant(species, 0);
  Species_setHasOnlySubstanceUnits(species, 0);

  species = Model_createSpecies(model);
  Species_setId(species, "ATPm");
  Species_setCompartment(species, "mitochon");
  Species_setBoundaryCondition(species, 0);
  Species_setConstant(species, 0);
  Species_setHasOnlySubstanceUnits(species, 0);

  // create the Groups
  // Get a SBasePlugin_t object plugged in the model object.

  modelPlug = SBase_getPlugin((SBase_t *)(model), "groups");

  // create the group object and add it to model plugin

  group = Group_create(3, 1, 1);
  Group_setId(group, "ATP");
  Group_setKind(group, GROUP_KIND_CLASSIFICATION);
  SBase_setSBOTerm(group, 252);

  member = Group_createMember(group);
  Member_setIdRef(member, "ATPc");

  member = Group_createMember(group);
  Member_setIdRef(member, "ATPm");

  // we need a function here
  GroupsModelPlugin_addGroup((GroupsModelPlugin_t*)(modelPlug), group);

  /* write the file */
  writeSBMLToFile(doc, "groups_example1.xml");

  return retval;
}