END_TEST START_TEST (test_SpeciesReference_setStoichiometryMath5) { SpeciesReference_t *sr1 = SpeciesReference_create(1, 2); StoichiometryMath_t * sm = StoichiometryMath_create(2, 4); 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); StoichiometryMath_setMath(sm, math); int i = SpeciesReference_setStoichiometryMath(sr1, sm); fail_unless( i == LIBSBML_UNEXPECTED_ATTRIBUTE); fail_unless( !SpeciesReference_isSetStoichiometryMath(sr1) ); StoichiometryMath_free(sm); SpeciesReference_free(sr1); }
END_TEST START_TEST (test_SpeciesReference_setStoichiometryMath) { const ASTNode_t *math = SBML_parseFormula("k3 / k2"); StoichiometryMath_t *stoich = StoichiometryMath_create(2, 4); StoichiometryMath_setMath(stoich, math); const StoichiometryMath_t * math1; char * formula; SpeciesReference_setStoichiometryMath(SR, stoich); math1 = SpeciesReference_getStoichiometryMath(SR); fail_unless( math1 != NULL ); formula = SBML_formulaToString(StoichiometryMath_getMath(math1)); fail_unless( formula != NULL ); fail_unless( !strcmp(formula, "k3 / k2") ); fail_unless( SpeciesReference_isSetStoichiometryMath(SR) ); safe_free(formula); }
END_TEST START_TEST (test_SpeciesReference_setStoichiometryMath1) { StoichiometryMath_t * sm = StoichiometryMath_create(2, 4); 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); StoichiometryMath_setMath(sm, math); int i = SpeciesReference_setStoichiometryMath(sr, sm); fail_unless( i == LIBSBML_OPERATION_SUCCESS); fail_unless( SpeciesReference_isSetStoichiometryMath(sr) ); fail_unless( SpeciesReference_getStoichiometry(sr) == 1 ); i = SpeciesReference_unsetStoichiometryMath(sr); fail_unless( i == LIBSBML_OPERATION_SUCCESS); fail_unless( !SpeciesReference_isSetStoichiometryMath(sr) ); StoichiometryMath_free(sm); }
END_TEST START_TEST (test_SpeciesReference_setStoichiometryMath6) { StoichiometryMath_t * sm = StoichiometryMath_create(2, 1); int i = SpeciesReference_setStoichiometryMath(sr, sm); fail_unless( i == LIBSBML_VERSION_MISMATCH); fail_unless( !SpeciesReference_isSetStoichiometryMath(sr) ); StoichiometryMath_free(sm); }
END_TEST START_TEST (test_SpeciesReference_setStoichiometryMath3) { int i = SpeciesReference_setStoichiometryMath(sr, NULL); fail_unless( i == LIBSBML_OPERATION_SUCCESS); fail_unless( !SpeciesReference_isSetStoichiometryMath(sr) ); i = SpeciesReference_unsetStoichiometryMath(sr); fail_unless( i == LIBSBML_OPERATION_SUCCESS); fail_unless( !SpeciesReference_isSetStoichiometryMath(sr) ); }
END_TEST START_TEST (test_SpeciesReference_setStoichiometryMath4) { StoichiometryMath_t * sm = StoichiometryMath_create(2, 4); ASTNode_t *math = NULL; StoichiometryMath_setMath(sm, math); int i = SpeciesReference_setStoichiometryMath(sr, sm); fail_unless( i == LIBSBML_OPERATION_SUCCESS); fail_unless( SpeciesReference_isSetStoichiometryMath(sr) ); fail_unless( SpeciesReference_getStoichiometry(sr) == 1 ); i = SpeciesReference_unsetStoichiometryMath(sr); fail_unless( i == LIBSBML_OPERATION_SUCCESS); fail_unless( !SpeciesReference_isSetStoichiometryMath(sr) ); StoichiometryMath_free(sm); }
END_TEST START_TEST (test_SpeciesReference_setStoichiometryMath2) { StoichiometryMath_t * sm = StoichiometryMath_create(2, 4); ASTNode_t *math = ASTNode_createWithType(AST_TIMES); ASTNode_t *a = ASTNode_create(); ASTNode_setName(a, "a"); ASTNode_addChild(math, a); StoichiometryMath_setMath(sm, math); int i = SpeciesReference_setStoichiometryMath(sr, sm); /* once the StoichiometryMath_setMath function does not set * an invalid ASTNode this changes to i == LIBSBML_OPERATION_SUCCESS fail_unless( i == LIBSBML_INVALID_OBJECT); */ fail_unless ( i == LIBSBML_OPERATION_SUCCESS ); fail_unless( SpeciesReference_isSetStoichiometryMath(sr) ); StoichiometryMath_free(sm); }