Exemplo n.º 1
0
END_TEST


START_TEST (test_Rule_setMath)
{
    ASTNode_t *math = SBML_parseFormula("1 + 1");


    Rule_setMath(R, math);

    fail_unless( Rule_getMath(R) != math );
    fail_unless( Rule_isSetMath(R) );

    /* Reflexive case (pathological) */
    Rule_setMath(R, (ASTNode_t *) Rule_getMath(R));
    fail_unless( Rule_getMath(R) != math );

    Rule_setMath(R, NULL);
    fail_unless( !Rule_isSetMath(R) );

    if (Rule_getMath(R) != NULL)
    {
        fail("Rule_setMath(R, NULL) did not clear ASTNode.");
    }
    ASTNode_free(math);
}
Exemplo n.º 2
0
END_TEST


START_TEST (test_Rule_setMath1)
{
  ASTNode_t *math = ASTNode_createWithType(AST_TIMES);
  ASTNode_t *a = ASTNode_create();
  ASTNode_t *b = ASTNode_create();
  ASTNode_setName(a, "a");
  ASTNode_setName(b, "b");
  ASTNode_addChild(math, a);
  ASTNode_addChild(math, b);
  char *formula;
  const ASTNode_t *math1;

  int i = Rule_setMath(R, math);

  fail_unless( i == LIBSBML_OPERATION_SUCCESS);
  fail_unless( Rule_isSetMath(R)   );

  math1 = Rule_getMath(R);
  fail_unless( math1 != NULL );

  formula = SBML_formulaToString(math1);
  fail_unless( formula != NULL );
  fail_unless( !strcmp(formula, "a * b") );

  ASTNode_free(math);
}
Exemplo n.º 3
0
END_TEST


START_TEST (test_Rule_setMath3)
{
  int i = Rule_setMath(R, NULL);

  fail_unless( i == LIBSBML_OPERATION_SUCCESS);
  fail_unless( !Rule_isSetMath(R)   );
}
Exemplo n.º 4
0
END_TEST


START_TEST (test_Rule_setMath2)
{
  ASTNode_t *math = ASTNode_createWithType(AST_DIVIDE);
  ASTNode_t *a = ASTNode_create();
  ASTNode_setName(a, "a");
  ASTNode_addChild(math, a);

  int i = Rule_setMath(R, math);

  fail_unless( i == LIBSBML_INVALID_OBJECT);
  fail_unless( !Rule_isSetMath(R)   );

  ASTNode_free(math);
}
Exemplo n.º 5
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);
}
Exemplo n.º 6
0
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);
}
Exemplo n.º 7
0
END_TEST


START_TEST (test_SBMLConvertStrict_convertL1ParamRule)
{
  SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(1, 2);
  Model_t * m = SBMLDocument_createModel(d);
  
  /* create a compartment */
  Compartment_t * c = Model_createCompartment(m);
  Compartment_setId(c, "c");

  /* create  a parameter */
  Parameter_t * p = Model_createParameter(m);
  Parameter_setId(p, "p");
  Parameter_t * p1 = Model_createParameter(m);
  Parameter_setId(p1, "p1");

  /* create a math element */
  ASTNode_t *math = SBML_parseFormula("p");

  /* create an assignment rule */
  Rule_t *ar = Model_createAssignmentRule(m);
  Rule_setVariable(ar, "p1");
  Rule_setMath(ar, math);
  Rule_setUnits(ar, "mole");

  fail_unless( SBMLDocument_setLevelAndVersionStrict(d, 2, 1) == 1 );
  fail_unless( SBMLDocument_getLevel  (d) == 2, NULL );
  fail_unless( SBMLDocument_getVersion(d) == 1, NULL );

  Rule_t * r1 = Model_getRule(SBMLDocument_getModel(d), 0);

  fail_unless (Rule_getUnits(r1) == NULL );

  SBMLDocument_free(d);
}