END_TEST START_TEST (test_ParameterRule_setUnits) { const char *units = "cell"; Rule_setUnits(PR, units); fail_unless( !strcmp(Rule_getUnits(PR), units) ); fail_unless( Rule_isSetUnits(PR) ); if (Rule_getUnits(PR) == units) { fail( "Rule_setUnits(...) did not make a copy of string." ); } /* Reflexive case (pathological) */ Rule_setUnits(PR, Rule_getUnits(PR)); fail_unless( !strcmp(Rule_getUnits(PR), units) ); Rule_setUnits(PR, NULL); fail_unless( !Rule_isSetUnits(PR) ); if (Rule_getUnits(PR) != NULL) { fail( "Rule_setUnits(PR, NULL) did not clear string." ); } }
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); }