END_TEST


START_TEST (test_FunctionDefinition_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);

  FunctionDefinition_t *object = 
    FunctionDefinition_createWithNS (sbmlns);


  fail_unless( SBase_getTypeCode  ((SBase_t *) object) == SBML_FUNCTION_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( FunctionDefinition_getNamespaces     (object) != NULL );
  fail_unless( XMLNamespaces_getLength(
                       FunctionDefinition_getNamespaces(object)) == 2 );

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


START_TEST (test_FunctionDefinition_free_NULL)
{
  FunctionDefinition_free(NULL);
}
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);
}
void
FunctionDefinitionTest1_teardown (void)
{
  FunctionDefinition_free(E);
}
void
FunctionDefinitionTest_teardown (void)
{
  FunctionDefinition_free(FD);
}