END_TEST START_TEST (test_Parameter_setName) { char *name = "Forward_Michaelis_Menten_Constant"; Parameter_setName(P, name); fail_unless( !strcmp(Parameter_getName(P), name) ); fail_unless( Parameter_isSetName(P) ); if (Parameter_getName(P) == name) { fail("Parameter_setName(...) did not make a copy of string."); } /* Reflexive case (pathological) */ Parameter_setName(P, Parameter_getName(P)); fail_unless( !strcmp(Parameter_getName(P), name) ); Parameter_setName(P, NULL); fail_unless( !Parameter_isSetName(P) ); if (Parameter_getName(P) != NULL) { fail("Parameter_setName(P, NULL) did not clear string."); } }
END_TEST START_TEST (test_L3_Parameter_name) { char *name = "My_Favorite_Factory"; fail_unless( !Parameter_isSetName(P) ); Parameter_setName(P, name); fail_unless( !strcmp(Parameter_getName(P), name) ); fail_unless( Parameter_isSetName(P) ); if (Parameter_getName(P) == name) { fail("Parameter_setName(...) did not make a copy of string."); } Parameter_unsetName(P); fail_unless( !Parameter_isSetName(P) ); if (Parameter_getName(P) != NULL) { fail("Parameter_unsetName(P) did not clear string."); } }
END_TEST START_TEST (test_Parameter_setName3) { Parameter_t *p = Parameter_create(1, 2); int i = Parameter_setName(p, "11pp"); fail_unless( i == LIBSBML_INVALID_ATTRIBUTE_VALUE ); fail_unless( !Parameter_isSetName(p) ); i = Parameter_setName(p, NULL); fail_unless( i == LIBSBML_OPERATION_SUCCESS ); fail_unless( !Parameter_isSetName(p) ); Parameter_free(p); }
END_TEST START_TEST (test_Parameter_setName1) { int i = Parameter_setName(P, "cell"); fail_unless( i == LIBSBML_OPERATION_SUCCESS ); fail_unless( Parameter_isSetName(P) ); i = Parameter_unsetName(P); fail_unless( i == LIBSBML_OPERATION_SUCCESS ); fail_unless( !Parameter_isSetName(P) ); }
END_TEST START_TEST (test_Parameter_setName2) { Parameter_t *p = Parameter_create(2, 2); int i = Parameter_setName(p, "1cell"); fail_unless( i == LIBSBML_OPERATION_SUCCESS ); fail_unless( Parameter_isSetName(p) ); i = Parameter_unsetName(p); fail_unless( i == LIBSBML_OPERATION_SUCCESS ); fail_unless( !Parameter_isSetName(p) ); Parameter_free(p); }
END_TEST START_TEST (test_create_l1v1_units) { Model_t *m; Compartment_t *c; KineticLaw_t *kl; Parameter_t *p; Reaction_t *r; Species_t *s; SpeciesReference_t *sr; Unit_t *u; UnitDefinition_t *ud; /** * <sbml level="1" version="1"> */ m = Model_create(2, 4); /** * <unitDefinition name="substance"> * <listOfUnits> * <unit kind="mole" scale="-3"/> * </listOfUnits> * </unitDefinition> */ ud = Model_createUnitDefinition(m); UnitDefinition_setName(ud, "substance"); u = Model_createUnit(m); Unit_setKind(u,UNIT_KIND_MOLE); Unit_setScale(u, -3); /** * <unitDefinition name="mls"> * <listOfUnits> * <unit kind="mole" scale="-3"/> * <unit kind="liter" exponent="-1"/> * <unit kind="second" exponent="-1"/> * </listOfUnits> * </unitDefinition> */ ud = Model_createUnitDefinition(m); UnitDefinition_setName(ud, "mls"); u = Model_createUnit(m); Unit_setKind(u, UNIT_KIND_MOLE); Unit_setScale(u, -3); u = Model_createUnit(m); Unit_setKind(u, UNIT_KIND_LITER); Unit_setExponent(u, -1); u = Model_createUnit(m); Unit_setKind(u, UNIT_KIND_SECOND); Unit_setExponent(u, -1); /** * <listOfCompartments> * <compartment name="cell"/> * </listOfCompartments> */ c = Model_createCompartment(m); Compartment_setName(c, "cell"); /** * <listOfSpecies> * <specie name="x0" compartment="cell" initialAmount="1"/> * <specie name="x1" compartment="cell" initialAmount="1"/> * <specie name="s1" compartment="cell" initialAmount="1"/> * <specie name="s2" compartment="cell" initialAmount="1"/> * </listOfSpecies> */ s = Model_createSpecies(m); Species_setName(s, "x0"); Species_setCompartment(s, "cell"); Species_setInitialAmount(s, 1); s = Model_createSpecies(m); Species_setName(s, "x1"); Species_setCompartment(s, "cell"); Species_setInitialAmount(s, 1); s = Model_createSpecies(m); Species_setName(s, "s1"); Species_setCompartment(s, "cell"); Species_setInitialAmount(s, 1); s = Model_createSpecies(m); Species_setName(s, "s2"); Species_setCompartment(s, "cell"); Species_setInitialAmount(s, 1); /** * <listOfParameters> * <parameter name="vm" value="2" units="mls"/> * <parameter name="km" value="2"/> * </listOfParameters> */ p = Model_createParameter(m); Parameter_setName (p, "vm"); Parameter_setUnits(p, "mls"); Parameter_setValue(p, 2); p = Model_createParameter(m); Parameter_setName (p, "km"); Parameter_setValue(p, 2); /** * <reaction name="v1"> * <listOfReactants> * <specieReference specie="x0"/> * </listOfReactants> * <listOfProducts> * <specieReference specie="s1"/> * </listOfProducts> * <kineticLaw formula="(vm * s1)/(km + s1)"/> * </reaction> */ r = Model_createReaction(m); Reaction_setName(r, "v1"); sr = Model_createReactant(m); SpeciesReference_setSpecies(sr, "x0"); sr = Model_createProduct(m); SpeciesReference_setSpecies(sr, "s1"); kl = Model_createKineticLaw(m); KineticLaw_setFormula(kl, "(vm * s1)/(km + s1)"); /** * <reaction name="v2"> * <listOfReactants> * <specieReference specie="s1"/> * </listOfReactants> * <listOfProducts> * <specieReference specie="s2"/> * </listOfProducts> * <kineticLaw formula="(vm * s2)/(km + s2)"/> * </reaction> */ r = Model_createReaction(m); Reaction_setName(r, "v2"); sr = Model_createReactant(m); SpeciesReference_setSpecies(sr, "s1"); sr = Model_createProduct(m); SpeciesReference_setSpecies(sr, "s2"); kl = Model_createKineticLaw(m); KineticLaw_setFormula(kl, "(vm * s2)/(km + s2)"); /** * <reaction name="v3"> * <listOfReactants> * <specieReference specie="s2"/> * </listOfReactants> * <listOfProducts> * <specieReference specie="x1"/> * </listOfProducts> * <kineticLaw formula="(vm * s1)/(km + s1)"/> * </reaction> */ r = Model_createReaction(m); Reaction_setName(r, "v3"); sr = Model_createReactant(m); SpeciesReference_setSpecies(sr, "s2"); sr = Model_createProduct(m); SpeciesReference_setSpecies(sr, "x1"); kl = Model_createKineticLaw(m); KineticLaw_setFormula(kl, "(vm * s1)/(km + s1)"); Model_free(m); }