Пример #1
0
void
printEventMath (unsigned int n, Event_t *e)
{
  char         *formula;
  unsigned int i;


  if ( Event_isSetDelay(e) )
  {
    formula = SBML_formulaToDot( Delay_getMath(Event_getDelay(e)) );
    fprintf(fout, "subgraph cluster%u {\n", noClusters);
    fprintf(fout, "label=\"Event %s delay:\";\n%s\n", Event_getId(e), formula);
    free(formula);
    noClusters++;
  }

  if ( Event_isSetTrigger(e) )
  {
    formula = SBML_formulaToDot( Trigger_getMath(Event_getTrigger(e)) );
    fprintf(fout, "subgraph cluster%u {\n", noClusters);
    fprintf(fout, "label=\"Event %s trigger:\";\n%s\n", Event_getId(e), formula);
    noClusters++;
    free(formula);
  }

  for (i = 0; i < Event_getNumEventAssignments(e); ++i)
  {
    printEventAssignmentMath(i + 1, Event_getEventAssignment(e, i));
  }
}
Пример #2
0
void
printEventMath (unsigned int n, Event_t *e)
{
  char         *formula;
  unsigned int i;


  if ( Event_isSetDelay(e) )
  {
    const Delay_t *delay = Event_getDelay(e);

    formula = SBML_formulaToString( Delay_getMath(delay) );
    printf("Event %d delay: %s\n", n, formula);
    free(formula);
  }

  if ( Event_isSetTrigger(e) )
  {
    const Trigger_t *trigger = Event_getTrigger(e);

    formula = SBML_formulaToString( Trigger_getMath(trigger) );
    printf("Event %d trigger: %s\n", n, formula);
    free(formula);
  }

  for (i = 0; i < Event_getNumEventAssignments(e); ++i)
  {
    printEventAssignmentMath(i + 1, Event_getEventAssignment(e, i));
  }

  printf("\n");
}
Пример #3
0
END_TEST


START_TEST (test_Trigger_setMath1)
{
    ASTNode_t *math = SBML_parseFormula("2 * k");

    int i = Trigger_setMath(D, math);

    fail_unless( i == LIBSBML_OPERATION_SUCCESS);
    fail_unless( Trigger_getMath(D) != math );
    fail_unless( Trigger_isSetMath(D) );

    i = Trigger_setMath(D, NULL);

    fail_unless( i == LIBSBML_OPERATION_SUCCESS);
    fail_unless( Trigger_getMath(D) == NULL );
    fail_unless( !Trigger_isSetMath(D) );

    ASTNode_free(math);
}
Пример #4
0
END_TEST


START_TEST (test_Trigger_setMath)
{
    ASTNode_t *math = SBML_parseFormula("lambda(x, x^3)");

    const ASTNode_t * math1;
    char * formula;

    Trigger_setMath(D, math);

    math1 = Trigger_getMath(D);
    fail_unless( math1 != NULL );

    formula = SBML_formulaToString(math1);
    fail_unless( formula != NULL );
    fail_unless( !strcmp(formula, "lambda(x, x^3)") );
    fail_unless( Trigger_getMath(D) != math );
    fail_unless( Trigger_isSetMath(D) );

    /* Reflexive case (pathological) */
    Trigger_setMath(D, (ASTNode_t *) Trigger_getMath(D));
    math1 = Trigger_getMath(D);
    fail_unless( math1 != NULL );

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

    Trigger_setMath(D, NULL);
    fail_unless( !Trigger_isSetMath(D) );

    if (Trigger_getMath(D) != NULL)
    {
        fail("Trigger_setMath(D, NULL) did not clear ASTNode.");
    }
}