END_TEST START_TEST (test_Compartment_initDefaults) { Compartment_t *c = Compartment_create(2, 4); Compartment_setId(c, "A"); Compartment_initDefaults(c); fail_unless( !strcmp(Compartment_getId (c), "A")); fail_unless( Compartment_getName (c) == NULL ); fail_unless( Compartment_getUnits (c) == NULL ); fail_unless( Compartment_getOutside(c) == NULL ); fail_unless( Compartment_getSpatialDimensions(c) == 3 ); fail_unless( Compartment_getVolume (c) == 1.0 ); fail_unless( Compartment_getConstant (c) == 1 ); fail_unless( Compartment_isSetId (c) ); fail_unless( !Compartment_isSetName (c) ); fail_unless( !Compartment_isSetSize (c) ); fail_unless( !Compartment_isSetVolume (c) ); fail_unless( !Compartment_isSetUnits (c) ); fail_unless( !Compartment_isSetOutside(c) ); fail_unless( Compartment_isSetSpatialDimensions(c) ); fail_unless( Compartment_isSetConstant(c) ); Compartment_free(c); }
END_TEST START_TEST (test_Compartment_createWith) { Compartment_t *c = Compartment_create(2, 4); Compartment_setId(c, "A"); fail_unless( SBase_getTypeCode ((SBase_t *) c) == SBML_COMPARTMENT ); fail_unless( SBase_getMetaId ((SBase_t *) c) == NULL ); fail_unless( SBase_getNotes ((SBase_t *) c) == NULL ); fail_unless( SBase_getAnnotation((SBase_t *) c) == NULL ); fail_unless( Compartment_getName(c) == NULL ); fail_unless( Compartment_getSpatialDimensions(c) == 3 ); fail_unless( !strcmp( Compartment_getId (c), "A" ) ); fail_unless( Compartment_getConstant(c) == 1 ); fail_unless( Compartment_isSetId (c) ); fail_unless( !Compartment_isSetName (c) ); Compartment_free(c); }
END_TEST /* since the setId function has been used as an * alias for setName we cant require it to only * be used on a L2 model START_TEST (test_Compartment_setId1) { int i = Compartment_setId(C, "cell"); fail_unless( i == LIBSBML_UNEXPECTED_ATTRIBUTE ); fail_unless( !Compartment_isSetId(C) ); } END_TEST */ START_TEST (test_Compartment_setId2) { Compartment_t *c = Compartment_create(2, 2); int i = Compartment_setId(c, "1cell"); fail_unless( i == LIBSBML_INVALID_ATTRIBUTE_VALUE ); fail_unless( !Compartment_isSetId(c) ); Compartment_free(c); }
END_TEST START_TEST (test_ListOf_append) { Model_t *m = Model_create(2, 4); Model_createCompartment(m); ListOf_t *loc = Model_getListOfCompartments(m); fail_unless(ListOf_size(loc) == 1); SBase_t *c = (SBase_t*)Compartment_create(2, 4); int i = ListOf_append(loc, c); fail_unless(i == LIBSBML_OPERATION_SUCCESS); fail_unless(ListOf_size(loc) == 2); SBase_t *sp = (SBase_t*)Species_create(2, 4); i = ListOf_append(loc, sp); fail_unless(i == LIBSBML_INVALID_OBJECT); fail_unless(ListOf_size(loc) == 2); Model_free(m); Species_free((Species_t*)sp); }
END_TEST START_TEST (test_SBMLConvert_convertToL1_Species_Amount) { SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(2, 4); Model_t *m = SBMLDocument_createModel(d); const char *sid = "C"; Compartment_t *c = Compartment_create(2, 4); Species_t *s = Species_create(2, 4); Compartment_setId ( c, sid ); Model_addCompartment( m, c ); Species_setCompartment ( s, sid ); Species_setInitialAmount( s, 2.34 ); Model_addSpecies ( m, s ); fail_unless( SBMLDocument_setLevelAndVersion(d, 1, 2) == 1, NULL ); fail_unless( Species_getInitialAmount(s) == 2.34, NULL ); SBMLDocument_free(d); }
void CompartmentTest_setup (void) { C = Compartment_create(2, 4); if (C == NULL) { fail("Compartment_create(2, 4) returned a NULL pointer."); } }
END_TEST START_TEST (test_Compartment_setConstant2) { Compartment_t *c = Compartment_create(2, 2); int i = Compartment_setConstant(c, 0); fail_unless( i == LIBSBML_OPERATION_SUCCESS ); fail_unless( Compartment_getConstant(c) == 0 ); Compartment_free(c); }
END_TEST START_TEST (test_Compartment_setSpatialDimensions5) { Compartment_t *c = Compartment_create(2, 2); int i = Compartment_setSpatialDimensionsAsDouble(c, 2.2); fail_unless( i == LIBSBML_INVALID_ATTRIBUTE_VALUE ); fail_unless( Compartment_getSpatialDimensions(c) == 3 ); Compartment_free(c); }
END_TEST START_TEST (test_Compartment_setSpatialDimensions4) { Compartment_t *c = Compartment_create(2, 2); int i = Compartment_setSpatialDimensionsAsDouble(c, 2.0); fail_unless( i == LIBSBML_OPERATION_SUCCESS ); fail_unless( Compartment_getSpatialDimensions(c) == 2 ); Compartment_free(c); }
END_TEST START_TEST (test_Compartment_setId4) { Compartment_t *c = Compartment_create(2, 2); int i = Compartment_setId(c, NULL); fail_unless( i == LIBSBML_OPERATION_SUCCESS ); fail_unless( !Compartment_isSetId(c) ); Compartment_free(c); }
END_TEST START_TEST (test_Compartment_setId3) { Compartment_t *c = Compartment_create(2, 2); int i = Compartment_setId(c, "cell"); fail_unless( i == LIBSBML_OPERATION_SUCCESS ); fail_unless( Compartment_isSetId(c) ); fail_unless( !strcmp(Compartment_getId(c), "cell" )); Compartment_free(c); }
END_TEST START_TEST (test_L3_Compartment_hasRequiredAttributes ) { Compartment_t *c = Compartment_create (3, 1); fail_unless ( !Compartment_hasRequiredAttributes(c)); Compartment_setId(c, "id"); fail_unless ( !Compartment_hasRequiredAttributes(c)); Compartment_setConstant(c, 0); fail_unless ( Compartment_hasRequiredAttributes(c)); Compartment_free(c); }
static Compartment_t * rsbml_build_doc_compartment(SEXP r_compartment) { Compartment_t * compartment; compartment = Compartment_create(); rsbml_build_doc_s_base((SBase_t *)compartment, r_compartment); SET_ATTR(Compartment, compartment, Id, id, STRING); SET_ATTR(Compartment, compartment, Name, name, STRING); SET_ATTR(Compartment, compartment, SpatialDimensions, spatialDimensions, INTEGER); SET_ATTR(Compartment, compartment, Size, size, REAL); SET_ATTR(Compartment, compartment, Units, units, STRING); SET_ATTR(Compartment, compartment, Outside, outside, STRING); SET_ATTR(Compartment, compartment, Constant, constant, LOGICAL); return compartment; }
END_TEST START_TEST (test_SBMLConvert_convertToL1_Species_Concentration) { SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(2, 1); Model_t *m = SBMLDocument_createModel(d); const char *sid = "C"; Compartment_t *c = Compartment_create(2, 1); Species_t *s = Species_create(2, 1); Compartment_setId ( c, sid ); Compartment_setSize ( c, 1.2 ); Model_addCompartment( m, c ); Species_setId ( s, "s" ); Species_setCompartment ( s, sid ); Species_setInitialConcentration( s, 2.34 ); Model_addSpecies ( m, s ); fail_unless( SBMLDocument_setLevelAndVersion(d, 1, 2) == 1, NULL); /** * These tests will fail under Cygwin because of a minimal * setlocale() implementation (see setlocale manpage). */ #ifndef CYGWIN fail_unless( Species_getInitialAmount(Model_getSpecies(m, 0)) == 2.808, NULL ); #endif Species_t * s1 = Model_getSpecies(m, 0); fail_unless (s1 != NULL); fail_unless (!strcmp(Species_getCompartment(s1), "C")); fail_unless(Compartment_getSize(Model_getCompartmentById(m, "C")) == 1.2); fail_unless(Species_getInitialConcentration(s1) == 2.34); fail_unless(Species_isSetInitialConcentration(s1) == 1); SBMLDocument_free(d); }
END_TEST START_TEST (test_Compartment_setCompartmentType2) { Compartment_t *c = Compartment_create(2, 2); int i = Compartment_setCompartmentType(c, "1cell"); fail_unless( i == LIBSBML_INVALID_ATTRIBUTE_VALUE ); fail_unless( !Compartment_isSetCompartmentType(c) ); i = Compartment_unsetCompartmentType(c); fail_unless( i == LIBSBML_OPERATION_SUCCESS ); fail_unless( !Compartment_isSetCompartmentType(c) ); Compartment_free(c); }
END_TEST START_TEST (test_Compartment_setVolume2) { Compartment_t *c = Compartment_create(2, 2); int i = Compartment_setVolume(c, 4); fail_unless( i == LIBSBML_OPERATION_SUCCESS ); fail_unless( Compartment_getVolume(c) == 4.0 ); fail_unless( Compartment_isSetVolume(c)); i = Compartment_unsetVolume(c); fail_unless( i == LIBSBML_OPERATION_SUCCESS ); fail_unless( !Compartment_isSetVolume(c)); Compartment_free(c); }