END_TEST

START_TEST ( test_LineSegment_createFrom )
{
   Point* start = new Point(LN,1.1,-2.2,3.3); 
   Point* end=new Point(LN,-4.4,5.5,-6.6); 
   LineSegment_setStart(LS,start);
   LineSegment_setEnd(LS,end);
   LineSegment_t* ls=LineSegment_createFrom(LS);
   
   
   fail_unless( SBase_getTypeCode   ((SBase_t*) ls) == SBML_LAYOUT_LINESEGMENT );
   
   if(SBase_isSetMetaId((SBase_t*)LS)){
     std::string c1=SBase_getMetaId((SBase_t*)LS);
     std::string c2=SBase_getMetaId((SBase_t*)ls);
     fail_unless( c1 == c2 );
   }
//   c1=SBase_getNotes((SBase_t*)LS);
//   c2=SBase_getNotes((SBase_t*)ls);
//   
//   if(SBase_isSetNotes((SBase_t*)LS))
//   {
//     fail_unless( strncmp(c1 , c2 ,strlen( c1 ) + 1 ) );
//   }
//   else
//   {
//     fail_unless(!(c1 || c2));
//   }
//   
//   c1=SBase_getAnnotation((SBase_t*)LS);
//   c2=SBase_getAnnotation((SBase_t*)ls);
//   
//   if(SBase_isSetAnnotation((SBase_t*)LS))
//   {
//     fail_unless( strncmp(c1 , c2 ,strlen( c1 ) + 1) );
//   }
//   else
//   {
//     fail_unless(!(c1 || c2));
//   }
   
   Point_t *pos=LineSegment_getStart(ls);
   Point_t *POS=LineSegment_getStart(LS);
   fail_unless(pos != NULL);
   fail_unless(Point_getXOffset(pos) == Point_getXOffset(POS));  
   fail_unless(Point_getYOffset(pos) == Point_getYOffset(POS));  
   fail_unless(Point_getZOffset(pos) == Point_getZOffset(POS));  
   
   pos=LineSegment_getEnd(ls);
   POS=LineSegment_getEnd(LS);
   fail_unless(pos != NULL);
   fail_unless(Point_getXOffset(pos) == Point_getXOffset(POS));  
   fail_unless(Point_getYOffset(pos) == Point_getYOffset(POS));  
   fail_unless(Point_getZOffset(pos) == Point_getZOffset(POS));  
 
   Point_free(start);
   Point_free(end);
   LineSegment_free(ls);
}
Ejemplo n.º 2
0
END_TEST


START_TEST (test_comp_deletion_metaid)
{
  const char *name = "delMetaId";


  fail_unless( !SBase_isSetMetaId(P) );

  SBase_setMetaId(P, name);

  const char* getmetaid = SBase_getMetaId(P);
  fail_unless( !strcmp(getmetaid, name) );
  fail_unless( SBase_isSetMetaId(P) );

  if (getmetaid == name)
  {
    fail("SBase_setMetaId(...) did not make a copy of string.");
  }

  SBase_unsetMetaId(P);
  
  fail_unless( !SBase_isSetMetaId(P) );

  if (SBase_getMetaId(P) != NULL)
  {
    fail("Deletion_unsetName(P) did not clear string.");
  }
}
Ejemplo n.º 3
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);
}
Ejemplo n.º 4
0
END_TEST


START_TEST (test_AssignmentRule_createWithFormula)
{
  const ASTNode_t *math;
  char *formula;

  Rule_t *ar = Rule_createAssignment(2, 4);
  Rule_setVariable(ar, "s");
  Rule_setFormula(ar, "1 + 1");


  fail_unless( SBase_getTypeCode  ((SBase_t *) ar) == SBML_ASSIGNMENT_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);
}
Ejemplo n.º 5
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);
}
Ejemplo n.º 6
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);
}
Ejemplo n.º 7
0
END_TEST

START_TEST ( test_LineSegment_createWithPoints_NULL )
{
   LineSegment_t *ls=LineSegment_createWithPoints(NULL,NULL);
   
   fail_unless( SBase_getTypeCode   ((SBase_t*) ls) == SBML_LAYOUT_LINESEGMENT );
   fail_unless( SBase_getMetaId     ((SBase_t*) ls) == NULL );
//   fail_unless( SBase_getNotes      ((SBase_t*) ls) == NULL );
//   fail_unless( SBase_getAnnotation ((SBase_t*) ls) == NULL );

   fail_unless( LineSegment_isSetId(ls) == 0 );
   
   Point_t *pos=LineSegment_getStart(ls);
   fail_unless(pos != NULL);
   fail_unless(Point_getXOffset(pos) == 0.0);  
   fail_unless(Point_getYOffset(pos) == 0.0);  
   fail_unless(Point_getZOffset(pos) == 0.0);  
   
   pos=LineSegment_getEnd(ls);
   fail_unless(pos != NULL);
   fail_unless(Point_getXOffset(pos) == 0.0);  
   fail_unless(Point_getYOffset(pos) == 0.0);  
   fail_unless(Point_getZOffset(pos) == 0.0);  
 
   LineSegment_free(ls);
}
Ejemplo n.º 8
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);
}
END_TEST


START_TEST ( test_LineSegment_createWithPoints )
{
   Point_t *start=new Point(LN,1.1,-2.2,3.3); 
   Point_t *end  =new Point(LN,-4.4,5.5,-6.6);

   LineSegment_t *ls=new LineSegment(LN, start,end);
   
   fail_unless( SBase_getTypeCode   ((SBase_t*) ls) == SBML_LAYOUT_LINESEGMENT );
   fail_unless( SBase_getMetaId     ((SBase_t*) ls) == NULL );
   
   Point_t *pos=LineSegment_getStart(ls);
   fail_unless(pos != NULL);
   fail_unless(Point_getXOffset(pos) == Point_getXOffset(start));  
   fail_unless(Point_getYOffset(pos) == Point_getYOffset(start));  
   fail_unless(Point_getZOffset(pos) == Point_getZOffset(start));  
   
   pos=LineSegment_getEnd(ls);
   fail_unless(pos != NULL);
   fail_unless(Point_getXOffset(pos) == Point_getXOffset(end));  
   fail_unless(Point_getYOffset(pos) == Point_getYOffset(end));  
   fail_unless(Point_getZOffset(pos) == Point_getZOffset(end));  

   Point_free(start);
   Point_free(end);

   LineSegment_free(ls);
  
}
Ejemplo n.º 10
0
END_TEST

START_TEST ( test_LineSegment_createWithCoordinates )
{
   LineSegment_t* ls=LineSegment_createWithCoordinates(1.1,-2.2,3.3,-4.4,5.5,-6.6);
    
   fail_unless( SBase_getTypeCode   ((SBase_t*) ls) == SBML_LAYOUT_LINESEGMENT );
   fail_unless( SBase_getMetaId     ((SBase_t*) ls) == NULL );
//   fail_unless( SBase_getNotes      ((SBase_t*) ls) == NULL );
//   fail_unless( SBase_getAnnotation ((SBase_t*) ls) == NULL );

   fail_unless( LineSegment_isSetId(ls) == 0 );
   
   Point_t *pos=LineSegment_getStart(ls);
   fail_unless(pos != NULL);
   fail_unless(pos->getXOffset() ==  1.1);  
   fail_unless(pos->getYOffset() == -2.2);  
   fail_unless(pos->getZOffset() ==  3.3);  
   
   pos=LineSegment_getEnd(ls);
   fail_unless(pos != NULL);
   fail_unless(pos->getXOffset() == -4.4);  
   fail_unless(pos->getYOffset() ==  5.5);  
   fail_unless(pos->getZOffset() == -6.6);  

   LineSegment_free(ls); 
}
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);
}
Ejemplo n.º 12
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);
}
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);
}
Ejemplo n.º 15
0
END_TEST


START_TEST (test_Compartment_createWith)
{
  Compartment_t *c = Compartment_create(2, 4);
    
  Compartment_setId(c, "A");


  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( Compartment_getName(c)              == NULL );
  fail_unless( Compartment_getSpatialDimensions(c) == 3    );

  fail_unless( !strcmp( Compartment_getId     (c), "A"     ) );

  fail_unless( Compartment_getConstant(c) == 1   );

  fail_unless( Compartment_isSetId     (c) );
  fail_unless( !Compartment_isSetName  (c) );

  Compartment_free(c);
}
Ejemplo n.º 16
0
END_TEST


START_TEST (test_AlgebraicRule_createWithFormula)
{
  const ASTNode_t *math;
  char *formula;

  AlgebraicRule_t *ar = AlgebraicRule_create(2, 4);
  AlgebraicRule_setFormula(ar, "1 + 1");


  fail_unless( SBase_getTypeCode  ((SBase_t *) ar) == SBML_ALGEBRAIC_RULE );
  fail_unless( SBase_getMetaId    ((SBase_t *) ar) == NULL );

  math = AlgebraicRule_getMath(ar);
  fail_unless(math != NULL);

  formula = SBML_formulaToString(math);
  fail_unless( formula != NULL );
  fail_unless( !strcmp(formula, "1 + 1") );

  fail_unless( !strcmp(AlgebraicRule_getFormula(ar), formula) );

  AlgebraicRule_free(ar);
  safe_free(formula);
}
Ejemplo n.º 17
0
END_TEST


START_TEST ( test_LineSegment_createWithPoints )
{
   Point_t *start=Point_createWithCoordinates(1.1,-2.2,3.3); 
   Point_t *end  =Point_createWithCoordinates(-4.4,5.5,-6.6);

   LineSegment_t *ls=LineSegment_createWithPoints(start,end);
   
   fail_unless( SBase_getTypeCode   ((SBase_t*) ls) == SBML_LAYOUT_LINESEGMENT );
   fail_unless( SBase_getMetaId     ((SBase_t*) ls) == NULL );
//   fail_unless( SBase_getNotes      ((SBase_t*) ls) == NULL );
//   fail_unless( SBase_getAnnotation ((SBase_t*) ls) == NULL );

   fail_unless( LineSegment_isSetId(ls) == 0 );
   
   Point_t *pos=LineSegment_getStart(ls);
   fail_unless(pos != NULL);
   fail_unless(Point_getXOffset(pos) == Point_getXOffset(start));  
   fail_unless(Point_getYOffset(pos) == Point_getYOffset(start));  
   fail_unless(Point_getZOffset(pos) == Point_getZOffset(start));  
   
   pos=LineSegment_getEnd(ls);
   fail_unless(pos != NULL);
   fail_unless(Point_getXOffset(pos) == Point_getXOffset(end));  
   fail_unless(Point_getYOffset(pos) == Point_getYOffset(end));  
   fail_unless(Point_getZOffset(pos) == Point_getZOffset(end));  

   Point_free(start);
   Point_free(end);

   LineSegment_free(ls);
  
}
Ejemplo n.º 18
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);
}
Ejemplo n.º 19
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);
}
Ejemplo n.º 20
0
BEGIN_C_DECLS

START_TEST (test_ListOf_create)
{
  ListOf_t *lo = (ListOf_t*) ListOf_create(2,4);


  fail_unless( SBase_getTypeCode  ((SBase_t *) lo) == SBML_LIST_OF );
  fail_unless( SBase_getNotes     ((SBase_t *) lo) == NULL );
  fail_unless( SBase_getAnnotation((SBase_t *) lo) == NULL );
  fail_unless( SBase_getMetaId    ((SBase_t *) lo) == NULL );

  fail_unless( ListOf_size(lo) == 0 );

  ListOf_free(lo);
}
END_TEST


//START_TEST (test_UnitDefinition_createWith)
//{
//  UnitDefinition_t *ud = UnitDefinition_createWith("mmls", "");
//
//
//  fail_unless( SBase_getTypeCode  ((SBase_t *) ud) == SBML_UNIT_DEFINITION );
//  fail_unless( SBase_getMetaId    ((SBase_t *) ud) == NULL );
//  fail_unless( SBase_getNotes     ((SBase_t *) ud) == NULL );
//  fail_unless( SBase_getAnnotation((SBase_t *) ud) == NULL );
//
//  fail_unless( UnitDefinition_getName(ud) == NULL );
//
//  fail_unless( !strcmp(UnitDefinition_getId(ud), "mmls") );
//  fail_unless(UnitDefinition_isSetId(ud));
//
//  fail_unless(UnitDefinition_getNumUnits(ud) == 0);
//
//  UnitDefinition_free(ud);
//}
//END_TEST


START_TEST (test_UnitDefinition_createWithName)
{
  UnitDefinition_t *ud = UnitDefinition_create(2, 4);
  UnitDefinition_setName(ud, "mmol_per_liter_per_sec");


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

  fail_unless( UnitDefinition_getId(ud) == NULL );

  fail_unless( !strcmp(UnitDefinition_getName(ud), "mmol_per_liter_per_sec"),
               NULL );

  fail_unless(UnitDefinition_isSetName(ud));

  fail_unless(UnitDefinition_getNumUnits(ud) == 0);

  UnitDefinition_free(ud);
}
END_TEST

START_TEST ( test_CubicBezier_createWithPoints )
{
   Point_t *start= new (std::nothrow) Point(LN,1.1,-2.2,3.3); 
   Point_t *base1= new (std::nothrow) Point(LN,-0.5,2.4,5.6); 
   Point_t *base2= new (std::nothrow) Point(LN,7.8,-0.3,-1.2); 
   Point_t *end  = new (std::nothrow) Point(LN,-4.4,5.5,-6.6);

   CubicBezier_t *cb= new CubicBezier(LN,start,base1,base2,end);
   
   fail_unless( cb->getPackageName() == "layout");
   fail_unless( cb->getTypeCode() == SBML_LAYOUT_CUBICBEZIER);
   fail_unless( SBase_getMetaId     ((SBase_t*) cb) == NULL );

   Point_t *pos=CubicBezier_getStart(cb);
   fail_unless(pos != NULL);
   fail_unless(Point_getXOffset(pos) == Point_getXOffset(start));  
   fail_unless(Point_getYOffset(pos) == Point_getYOffset(start));  
   fail_unless(Point_getZOffset(pos) == Point_getZOffset(start));  
   
   pos=CubicBezier_getBasePoint1(cb);
   fail_unless(pos != NULL);
   fail_unless(Point_getXOffset(pos) == Point_getXOffset(base1));  
   fail_unless(Point_getYOffset(pos) == Point_getYOffset(base1));  
   fail_unless(Point_getZOffset(pos) == Point_getZOffset(base1));  

   pos=CubicBezier_getBasePoint2(cb);
   fail_unless(pos != NULL);
   fail_unless(Point_getXOffset(pos) == Point_getXOffset(base2));  
   fail_unless(Point_getYOffset(pos) == Point_getYOffset(base2));  
   fail_unless(Point_getZOffset(pos) == Point_getZOffset(base2));  
   
   pos=CubicBezier_getEnd(cb);
   fail_unless(pos != NULL);
   fail_unless(Point_getXOffset(pos) == Point_getXOffset(end));  
   fail_unless(Point_getYOffset(pos) == Point_getYOffset(end));  
   fail_unless(Point_getZOffset(pos) == Point_getZOffset(end));  

    Point_free(start);
    Point_free(base1);
    Point_free(base2);
    Point_free(end);
    CubicBezier_free(cb);
}
Ejemplo n.º 23
0
END_TEST


START_TEST (test_AlgebraicRule_createWithMath)
{
  ASTNode_t       *math = SBML_parseFormula("1 + 1");
  Rule_t *ar   = Rule_createAlgebraic(2, 4);
  Rule_setMath(ar, math);


  fail_unless( SBase_getTypeCode  ((SBase_t *) ar) == SBML_ALGEBRAIC_RULE );
  fail_unless( SBase_getMetaId    ((SBase_t *) ar) == NULL );

  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_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);
}
Ejemplo n.º 25
0
END_TEST


START_TEST (test_AssignmentRule_createWithMath)
{
  ASTNode_t       *math = SBML_parseFormula("1 + 1");

  Rule_t *ar = Rule_createAssignment(2, 4);
  Rule_setVariable(ar, "s");
  Rule_setMath(ar, math);


  fail_unless( SBase_getTypeCode  ((SBase_t *) ar) == SBML_ASSIGNMENT_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_CubicBezier_createWithPoints_NULL )
{
	Point* nullPoint = NULL;
   CubicBezier_t *cb=new CubicBezier(LN,
									 nullPoint,
									 nullPoint,
									 nullPoint,
									 nullPoint);
   
   fail_unless( cb->getPackageName() == "layout");
   fail_unless( cb->getTypeCode() == SBML_LAYOUT_CUBICBEZIER);
   fail_unless( SBase_getMetaId     ((SBase_t*) cb) == NULL );

   Point_t *pos=CubicBezier_getStart(cb);
   fail_unless(pos != NULL);
   fail_unless(Point_getXOffset(pos) == 0.0);  
   fail_unless(Point_getYOffset(pos) == 0.0);  
   fail_unless(Point_getZOffset(pos) == 0.0);  
   
   pos=CubicBezier_getBasePoint1(cb);
   fail_unless(pos != NULL);
   fail_unless(Point_getXOffset(pos) == 0.0);  
   fail_unless(Point_getYOffset(pos) == 0.0);  
   fail_unless(Point_getZOffset(pos) == 0.0);  

   pos=CubicBezier_getBasePoint2(cb);
   fail_unless(pos != NULL);
   fail_unless(Point_getXOffset(pos) == 0.0);  
   fail_unless(Point_getYOffset(pos) == 0.0);  
   fail_unless(Point_getZOffset(pos) == 0.0);  
   
   pos=CubicBezier_getEnd(cb);
   fail_unless(pos != NULL);
   fail_unless(Point_getXOffset(pos) == 0.0);  
   fail_unless(Point_getYOffset(pos) == 0.0);  
   fail_unless(Point_getZOffset(pos) == 0.0);  
 
   CubicBezier_free(cb);
}
Ejemplo n.º 27
0
END_TEST

START_TEST ( test_CubicBezier_createWithCoordinates )
{
  Point p1(LN,1.1,-2.2,3.3);
  Point p2(LN,-4.4,5.5,-6.6);
  Point p3(LN,7.7,-8.8,9.9);
  Point p4(LN,-10.10,11.11,-12.12);

  CubicBezier_t* cb= new CubicBezier(LN, &p1, &p2, &p3, &p4);
  
  fail_unless( cb->getPackageName() == "layout");
  fail_unless( cb->getTypeCode() == SBML_LAYOUT_CUBICBEZIER);
  fail_unless( SBase_getMetaId     ((SBase_t*) cb) == NULL );
  
  Point_t *pos=CubicBezier_getStart(cb);
  fail_unless(pos != NULL);
  fail_unless(pos->getXOffset() ==  1.1);
  fail_unless(pos->getYOffset() == -2.2);
  fail_unless(pos->getZOffset() ==  3.3);
  
  pos=CubicBezier_getBasePoint1(cb);
  fail_unless(pos != NULL);
  fail_unless(pos->getXOffset() == -4.4);
  fail_unless(pos->getYOffset() ==  5.5);
  fail_unless(pos->getZOffset() == -6.6);
  
  pos=CubicBezier_getBasePoint2(cb);
  fail_unless(pos != NULL);
  fail_unless(pos->getXOffset() ==  7.7);
  fail_unless(pos->getYOffset() == -8.8);
  fail_unless(pos->getZOffset() ==  9.9);
  
  pos=CubicBezier_getEnd(cb);
  fail_unless(pos != NULL);
  fail_unless(pos->getXOffset() == -10.10);
  fail_unless(pos->getYOffset() ==  11.11);
  fail_unless(pos->getZOffset() == -12.12);
  
  CubicBezier_free(cb);
}
Ejemplo n.º 28
0
END_TEST


START_TEST (test_SBMLConvertStrict_convertToL1)
{
  SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(2, 4);
  
  /* create model with metaid */
  Model_t * m = SBMLDocument_createModel(d);
  SBase_setMetaId((SBase_t *) (m), "_m");
  
  /* create a compartment with sbo*/
  Compartment_t * c = Model_createCompartment(m);
  Compartment_setId(c, "c");
  SBase_setSBOTerm((SBase_t *) (c), 240);

  /* create a species with hasOnlySubstanceUnits = true*/
  Species_t *s = Model_createSpecies(m);
  Species_setId(s, "s");
  Species_setCompartment(s, "c");
  Species_setHasOnlySubstanceUnits(s, 1);

  fail_unless( SBMLDocument_setLevelAndVersionStrict(d, 1, 2) == 1 );
  fail_unless( SBMLDocument_getLevel  (d) == 1, NULL );
  fail_unless( SBMLDocument_getVersion(d) == 2, NULL );

  ///* check that attributes that are no longer valid have been removed */
  Model_t * m1 = SBMLDocument_getModel(d);

  fail_unless (SBase_getMetaId((SBase_t *) (m1)) == NULL);

  Compartment_t *c1 = Model_getCompartment(m1, 0);

  fail_unless (SBase_getSBOTerm((SBase_t *) (c1)) == -1, NULL );

  Species_t *s1 = Model_getSpecies(m1, 0);

  fail_unless (Species_getHasOnlySubstanceUnits(s1) == 0);

  SBMLDocument_free(d);
}
Ejemplo n.º 29
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);
}
Ejemplo n.º 30
0
END_TEST


//START_TEST (test_SpeciesReference_createWith)
//{
//  SpeciesReference_t *sr = SpeciesReference_createWithSpeciesAndStoichiometry("s3", 4, 2);
//
//
//  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( !strcmp(SpeciesReference_getSpecies(sr), "s3") );
//
//  fail_unless( SpeciesReference_getStoichiometry(sr) == 4    );
//  fail_unless( SpeciesReference_getDenominator  (sr) == 2    );
//
//  fail_unless( SpeciesReference_isSetSpecies(sr) );
//
//  SpeciesReference_free(sr);
//}
//END_TEST


START_TEST (test_SpeciesReference_createModifier)
{
  SpeciesReference_t *sr = 
    SpeciesReference_createModifier(2, 4);


  fail_unless( SBase_getTypeCode  ((SBase_t *) sr) == SBML_MODIFIER_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( SpeciesReference_isModifier(sr));
  SpeciesReference_free(sr);
}