Ejemplo n.º 1
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);
}
Ejemplo n.º 2
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.");
    }
}
Ejemplo n.º 3
0
END_TEST


START_TEST (test_Trigger_setMath2)
{
    ASTNode_t *math = ASTNode_createWithType(AST_TIMES);

    int i = Trigger_setMath(D, math);

    fail_unless( i == LIBSBML_INVALID_OBJECT);
    fail_unless( !Trigger_isSetMath(D) );

    ASTNode_free(math);
}
END_TEST


START_TEST (test_Event_setTrigger1)
{
  Trigger_t   *trigger 
    = Trigger_create(2, 1);
  Trigger_setMath(trigger, SBML_parseFormula("true"));
 
  int i = Event_setTrigger(E, trigger);

  fail_unless( i == LIBSBML_VERSION_MISMATCH );
  fail_unless( !Event_isSetTrigger(E) );

}
END_TEST


START_TEST (test_Event_setTrigger2)
{
  ASTNode_t         *math1   = SBML_parseFormula("0");
  Trigger_t   *trigger 
    = Trigger_create(2, 4);
  Trigger_setMath(trigger, math1);
 
  int i = Event_setTrigger(E, trigger);

  fail_unless( i == LIBSBML_OPERATION_SUCCESS );
  fail_unless( Event_getTrigger(E) != NULL );
  fail_unless( Event_isSetTrigger(E) );

}
Ejemplo n.º 6
0
END_TEST


START_TEST (test_L3_Event_hasRequiredElements )
{
  Event_t *e = Event_create (3, 1);

  fail_unless ( !Event_hasRequiredElements(e));

  Trigger_t *t = Trigger_create(3, 1);
  ASTNode_t* math = SBML_parseFormula("true");
  Trigger_setMath(t, math);
  ASTNode_free(math);
  Trigger_setInitialValue(t, 1);
  Trigger_setPersistent(t, 1);
  Event_setTrigger(e, t);

  fail_unless ( Event_hasRequiredElements(e));

  Event_free(e);
  Trigger_free(t);
}