void
FunctionDefinitionTest1_setup (void)
{
  E = FunctionDefinition_create(2, 4);

  if (E == NULL)
  {
    fail("FunctionDefinition_create() returned a NULL pointer.");
  }
}
Beispiel #2
0
Datei: doc.c Projekt: cran/rsbml
static FunctionDefinition_t *
rsbml_build_doc_function_definition(SEXP r_function_definition)
{
  FunctionDefinition_t * function_definition;
  
  function_definition = FunctionDefinition_create();
  
  rsbml_build_doc_s_base((SBase_t *)function_definition, r_function_definition);
  
  SET_ATTR(FunctionDefinition, function_definition, Id, id, STRING);
  SET_ATTR(FunctionDefinition, function_definition, Name, name, STRING);
  SET_ATTR(FunctionDefinition, function_definition, Math, math, EXPRESSION);
  
  return function_definition;
}
END_TEST


START_TEST (test_FunctionDefinition_createWith)
{
  ASTNode_t            *math = SBML_parseFormula("lambda(x, x^3)");
  FunctionDefinition_t *fd   = 
    FunctionDefinition_create(2, 4);
  FunctionDefinition_setId(fd, "pow3");
  FunctionDefinition_setMath(fd, math);

  const ASTNode_t * math1;
  char * formula;

  fail_unless( SBase_getTypeCode((SBase_t *) fd) == SBML_FUNCTION_DEFINITION );
  fail_unless( SBase_getMetaId    ((SBase_t *) fd) == NULL );
  fail_unless( SBase_getNotes     ((SBase_t *) fd) == NULL );
  fail_unless( SBase_getAnnotation((SBase_t *) fd) == NULL );

  fail_unless( FunctionDefinition_getName(fd) == NULL );

  math1 = FunctionDefinition_getMath(fd);
  fail_unless( math1 != NULL );

  formula = SBML_formulaToString(math1);
  fail_unless( formula != NULL );
  fail_unless( !strcmp(formula, "lambda(x, x^3)") );
  fail_unless( FunctionDefinition_getMath(fd) != math );
  fail_unless( FunctionDefinition_isSetMath(fd) );

  fail_unless( !strcmp(FunctionDefinition_getId(fd), "pow3") );
  fail_unless( FunctionDefinition_isSetId(fd) );

  ASTNode_free(math);
  safe_free(formula);
  FunctionDefinition_free(fd);
}