END_TEST


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

  Rule_t *ar = Rule_createAlgebraic(2, 4);
  Rule_setFormula(ar, "1 + 1");


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

  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_AssignmentRule_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_createAssignmentWithNS(sbmlns);


  fail_unless( SBase_getTypeCode  ((SBase_t *) object) == SBML_ASSIGNMENT_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);
}
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);

  Rule_t *r = 
    Rule_createAlgebraicWithNS(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     (r) != NULL );
  fail_unless( XMLNamespaces_getLength(Rule_getNamespaces(r)) == 2 );


  Rule_free(r);
}
END_TEST


START_TEST (test_AssignmentRule_free_NULL)
{
  Rule_free(NULL);
}
END_TEST


START_TEST (test_AlgebraicRule_free_NULL)
{
  Rule_free(NULL);
}
END_TEST


//START_TEST (test_SpeciesConcentrationRule_createWith)
//{
//  Rule_t *scr;
//
//
//  scr = Rule_createRateWithVariableAndFormula("c", "v + 1");
//  Rule_setL1TypeCode(scr, SBML_SPECIES_CONCENTRATION_RULE);
//
//  fail_unless( SBase_getTypeCode((SBase_t *) scr) ==
//               SBML_RATE_RULE );
//  fail_unless( Rule_getL1TypeCode((Rule_t *) scr) ==
//               SBML_SPECIES_CONCENTRATION_RULE );
//
//  fail_unless( SBase_getNotes     ((SBase_t *) scr) == NULL );
//  fail_unless( SBase_getAnnotation((SBase_t *) scr) == NULL );
//
//  fail_unless( !strcmp(Rule_getFormula( scr), "v + 1") );
//  fail_unless( !strcmp(Rule_getVariable(scr), "c") );
//
//  fail_unless( Rule_getType( scr) ==  RULE_TYPE_RATE );
//
//  fail_unless( Rule_isSetVariable(scr) );
//
//  Rule_free(scr);
//}
//END_TEST


START_TEST (test_SpeciesConcentrationRule_free_NULL)
{
  Rule_free(NULL);
}
END_TEST


START_TEST (test_RateRule_free_NULL)
{
  Rule_free(NULL);
}
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);
}
END_TEST


START_TEST (test_Rule_setVariable3)
{
  Rule_t *R1 = 
    Rule_createAlgebraic(1, 2);
  
  int i = Rule_setVariable(R1, "r");

  fail_unless( i == LIBSBML_UNEXPECTED_ATTRIBUTE);
  fail_unless( !Rule_isSetVariable(R1)   );

  Rule_free(R1);
}
Beispiel #10
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_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_Rule_setUnits3)
{
  Rule_t *R1 = 
    Rule_createAssignment(1, 2);
  Rule_setL1TypeCode(R1, SBML_PARAMETER_RULE);
  
  int i = Rule_setUnits(R1, "1second");

  fail_unless( i == LIBSBML_INVALID_ATTRIBUTE_VALUE);
  fail_unless( !Rule_isSetUnits(R1)   );

  i = Rule_unsetUnits(R1);

  fail_unless( i == LIBSBML_OPERATION_SUCCESS);
  fail_unless( !Rule_isSetUnits(R1)   );

  Rule_free(R1);
}
END_TEST


START_TEST (test_Rule_setUnits4)
{
  Rule_t *R1 = 
    Rule_createAssignment(1, 2);
  Rule_setL1TypeCode(R1, SBML_PARAMETER_RULE);

  int i = Rule_setUnits(R1, "second");

  fail_unless( i == LIBSBML_OPERATION_SUCCESS);
  fail_unless( Rule_isSetUnits(R1)   );

  i = Rule_setUnits(R1, NULL);

  fail_unless( i == LIBSBML_OPERATION_SUCCESS);
  fail_unless( !Rule_isSetUnits(R1)   );

  Rule_free(R1);
}
Beispiel #14
0
END_TEST


//START_TEST (test_ParameterRule_createWith)
//{
//  Rule_t *pr;
//
//
//  pr = Rule_createRateWithVariableAndFormula("c", "v + 1");
//  Rule_setL1TypeCode(pr, SBML_PARAMETER_RULE);
//
//  fail_unless( SBase_getTypeCode((SBase_t *) pr) ==
//               SBML_RATE_RULE );
//  fail_unless( Rule_getL1TypeCode((Rule_t *) pr) ==
//               SBML_PARAMETER_RULE );
//  fail_unless( SBase_getNotes     ((SBase_t *) pr) == NULL );
//  fail_unless( SBase_getAnnotation((SBase_t *) pr) == NULL );
//
//  fail_unless( Rule_getUnits(pr) == NULL );
//
//  fail_unless( !strcmp(Rule_getFormula(pr), "v + 1") );
//  fail_unless( !strcmp(Rule_getVariable(pr), "c") );
//
//  fail_unless( Rule_getType( pr) ==  RULE_TYPE_RATE );
//
//  fail_unless( Rule_isSetVariable(pr) );
//  fail_unless( !Rule_isSetUnits(pr) );
//
//  Rule_free(pr);
//}
//END_TEST


START_TEST (test_ParameterRule_free_NULL)
{
  Rule_free(NULL);
}
END_TEST


//START_TEST (test_CompartmentVolumeRule_createWith)
//{
//  Rule_t *cvr;
//
//
//  cvr = Rule_createRateWithVariableAndFormula("c", "v + 1");
//  Rule_setL1TypeCode(cvr, SBML_COMPARTMENT_VOLUME_RULE);
//
//  fail_unless( SBase_getTypeCode((SBase_t *) cvr) ==
//               SBML_RATE_RULE );
//  fail_unless( Rule_getL1TypeCode((Rule_t *) cvr) ==
//               SBML_COMPARTMENT_VOLUME_RULE );
//
//  fail_unless( SBase_getNotes     ((SBase_t *) cvr) == NULL );
//  fail_unless( SBase_getAnnotation((SBase_t *) cvr) == NULL );
//
//
//  fail_unless( !strcmp(Rule_getFormula(cvr), "v + 1") );
//  fail_unless( !strcmp(Rule_getVariable(cvr), "c") );
//
//  fail_unless( Rule_getType(cvr) ==   RULE_TYPE_RATE );
//
//  fail_unless( Rule_isSetVariable(cvr) );
//
//  Rule_free(cvr);
//}
//END_TEST


START_TEST (test_CompartmentVolumeRule_free_NULL)
{
  Rule_free(NULL);
}
void
SpeciesConcentrationRuleTest_teardown (void)
{
  Rule_free(SCR);
}
Beispiel #17
0
void
AlgebraicRuleTest_teardown (void)
{
  Rule_free((Rule_t*)(AR));
}
void
CompartmentVolumeRuleTest_teardown (void)
{
  Rule_free(CVR);
}
Beispiel #19
0
void
AlgebraicRuleTest_teardown (void)
{
  Rule_free(AR);
}
void
AssignmentRuleTest_teardown (void)
{
  Rule_free(AR);
}
Beispiel #21
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);
}
Beispiel #22
0
void
RateRuleTest_teardown (void)
{
  Rule_free(RR);
}
void
RuleTest1_teardown (void)
{
  Rule_free(R);
}
Beispiel #24
0
void
ParameterRuleTest_teardown (void)
{
  Rule_free(PR);
}