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_Rule_setUnits1) { int i = Rule_setUnits(R, "second"); fail_unless( i == LIBSBML_UNEXPECTED_ATTRIBUTE); fail_unless( !Rule_isSetUnits(R) ); }
END_TEST START_TEST (test_Rule_setUnits4) { Rule_t *R1 = Rule_createAssignment(1, 2); Rule_setL1TypeCode(R1, SBML_PARAMETER_RULE); int i = Rule_setUnits(R1, "second"); fail_unless( i == LIBSBML_OPERATION_SUCCESS); fail_unless( Rule_isSetUnits(R1) ); i = Rule_setUnits(R1, NULL); fail_unless( i == LIBSBML_OPERATION_SUCCESS); fail_unless( !Rule_isSetUnits(R1) ); Rule_free(R1); }
END_TEST START_TEST (test_Rule_setUnits3) { Rule_t *R1 = Rule_createAssignment(1, 2); Rule_setL1TypeCode(R1, SBML_PARAMETER_RULE); int i = Rule_setUnits(R1, "1second"); fail_unless( i == LIBSBML_INVALID_ATTRIBUTE_VALUE); fail_unless( !Rule_isSetUnits(R1) ); i = Rule_unsetUnits(R1); fail_unless( i == LIBSBML_OPERATION_SUCCESS); fail_unless( !Rule_isSetUnits(R1) ); Rule_free(R1); }
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); }