END_TEST START_TEST (test_Species_setCompartment) { const char *compartment = "cell"; Species_setCompartment(S, compartment); fail_unless( !strcmp(Species_getCompartment(S), compartment) ); fail_unless( Species_isSetCompartment(S) ); if (Species_getCompartment(S) == compartment) { fail("Species_setCompartment(...) did not make a copy of string."); } /* Reflexive case (pathological) */ Species_setCompartment(S, Species_getCompartment(S)); fail_unless( !strcmp(Species_getCompartment(S), compartment) ); Species_setCompartment(S, NULL); fail_unless( !Species_isSetCompartment(S) ); if (Species_getCompartment(S) != NULL) { fail("Species_setComartment(S, NULL) did not clear string."); } }
END_TEST START_TEST (test_Species_unsetCompartment) { const char *compartment = "cell"; Species_setCompartment(S, compartment); fail_unless( !strcmp(Species_getCompartment(S), compartment) ); fail_unless( Species_isSetCompartment(S) ); if (Species_getCompartment(S) == compartment) { fail("Species_setCompartment(...) did not make a copy of string."); } Species_unsetCompartment(S); fail_unless( !Species_isSetCompartment(S) ); if (Species_getCompartment(S) != NULL) { fail("Species_unsetComartment(S) did not clear string."); } }
END_TEST START_TEST (test_L3_Species_initDefaults) { Species_t *s = Species_create(3,1); fail_unless( Species_getId (s) == NULL ); fail_unless( Species_getName (s) == NULL ); fail_unless( Species_getCompartment (s) == NULL ); fail_unless( util_isNaN(Species_getInitialAmount (s)) ); fail_unless( util_isNaN(Species_getInitialConcentration (s)) ); fail_unless( Species_getSubstanceUnits (s) == NULL ); fail_unless( Species_getHasOnlySubstanceUnits(s) == 0 ); fail_unless( Species_getBoundaryCondition(s) == 0 ); fail_unless( Species_getConstant(s) == 0 ); fail_unless( Species_getConversionFactor (s) == NULL ); fail_unless( !Species_isSetId (s) ); fail_unless( !Species_isSetName (s) ); fail_unless( !Species_isSetCompartment (s) ); fail_unless( !Species_isSetInitialAmount (s) ); fail_unless( !Species_isSetInitialConcentration (s) ); fail_unless( !Species_isSetSubstanceUnits (s) ); fail_unless( !Species_isSetHasOnlySubstanceUnits(s) ); fail_unless( !Species_isSetBoundaryCondition(s) ); fail_unless( !Species_isSetConstant(s) ); fail_unless( !Species_isSetConversionFactor (s) ); Species_initDefaults(s); fail_unless( Species_getId (s) == NULL ); fail_unless( Species_getName (s) == NULL ); fail_unless( Species_getCompartment (s) == NULL ); fail_unless( util_isNaN(Species_getInitialAmount (s)) ); fail_unless( util_isNaN(Species_getInitialConcentration (s)) ); fail_unless( !strcmp(Species_getSubstanceUnits (s),"mole" )); fail_unless( Species_getHasOnlySubstanceUnits(s) == 0 ); fail_unless( Species_getBoundaryCondition(s) == 0 ); fail_unless( Species_getConstant(s) == 0 ); fail_unless( Species_getConversionFactor (s) == NULL ); fail_unless( !Species_isSetId (s) ); fail_unless( !Species_isSetName (s) ); fail_unless( !Species_isSetCompartment (s) ); fail_unless( !Species_isSetInitialAmount (s) ); fail_unless( !Species_isSetInitialConcentration (s) ); fail_unless( Species_isSetSubstanceUnits (s) ); fail_unless( Species_isSetHasOnlySubstanceUnits(s) ); fail_unless( Species_isSetBoundaryCondition(s) ); fail_unless( Species_isSetConstant(s) ); fail_unless( !Species_isSetConversionFactor (s) ); Species_free(s); }
END_TEST START_TEST (test_Species_setCompartment2) { int i = Species_setCompartment(C, "cell"); fail_unless( i == LIBSBML_OPERATION_SUCCESS ); fail_unless( Species_isSetCompartment(C) ); i = Species_setCompartment(C, ""); fail_unless( i == LIBSBML_OPERATION_SUCCESS ); fail_unless( !Species_isSetCompartment(C) ); }
END_TEST START_TEST (test_Species_setCompartment1) { int i = Species_setCompartment(C, "1cell"); fail_unless( i == LIBSBML_INVALID_ATTRIBUTE_VALUE ); fail_unless( !Species_isSetCompartment(C) ); i = Species_setCompartment(C, ""); fail_unless( i == LIBSBML_OPERATION_SUCCESS ); fail_unless( !Species_isSetCompartment(C) ); }
END_TEST START_TEST (test_L3_Species_compartment) { char *compartment = "cell"; fail_unless( !Species_isSetCompartment(S) ); Species_setCompartment(S, compartment); fail_unless( !strcmp(Species_getCompartment(S), compartment) ); fail_unless( Species_isSetCompartment(S) ); if (Species_getCompartment(S) == compartment) { fail("Species_setCompartment(...) did not make a copy of string."); } }
END_TEST START_TEST (test_L3_Species_createWithNS ) { XMLNamespaces_t *xmlns = XMLNamespaces_create(); XMLNamespaces_add(xmlns, "http://www.sbml.org", "testsbml"); SBMLNamespaces_t *sbmlns = SBMLNamespaces_create(3,1); SBMLNamespaces_addNamespaces(sbmlns,xmlns); Species_t *s = Species_createWithNS (sbmlns); fail_unless( SBase_getTypeCode ((SBase_t *) s) == SBML_SPECIES ); fail_unless( SBase_getMetaId ((SBase_t *) s) == NULL ); fail_unless( SBase_getNotes ((SBase_t *) s) == NULL ); fail_unless( SBase_getAnnotation((SBase_t *) s) == NULL ); fail_unless( SBase_getLevel ((SBase_t *) s) == 3 ); fail_unless( SBase_getVersion ((SBase_t *) s) == 1 ); fail_unless( Species_getNamespaces (s) != NULL ); fail_unless( XMLNamespaces_getLength(Species_getNamespaces(s)) == 2 ); fail_unless( Species_getId (s) == NULL ); fail_unless( Species_getName (s) == NULL ); fail_unless( Species_getCompartment (s) == NULL ); fail_unless( util_isNaN(Species_getInitialAmount (s)) ); fail_unless( util_isNaN(Species_getInitialConcentration (s)) ); fail_unless( Species_getSubstanceUnits (s) == NULL ); fail_unless( Species_getHasOnlySubstanceUnits(s) == 0 ); fail_unless( Species_getBoundaryCondition(s) == 0 ); fail_unless( Species_getConstant(s) == 0 ); fail_unless( Species_getConversionFactor (s) == NULL ); fail_unless( !Species_isSetId (s) ); fail_unless( !Species_isSetName (s) ); fail_unless( !Species_isSetCompartment (s) ); fail_unless( !Species_isSetInitialAmount (s) ); fail_unless( !Species_isSetInitialConcentration (s) ); fail_unless( !Species_isSetSubstanceUnits (s) ); fail_unless( !Species_isSetHasOnlySubstanceUnits(s) ); fail_unless( !Species_isSetBoundaryCondition(s) ); fail_unless( !Species_isSetConstant(s) ); fail_unless( !Species_isSetConversionFactor (s) ); Species_free(s); XMLNamespaces_free(xmlns); SBMLNamespaces_free(sbmlns); }