END_TEST


START_TEST (test_SBMLConvert_convertToL3_defaultUnits)
{
  SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(1, 2);
  Model_t        *m = SBMLDocument_createModel(d);

  const char   *sid = "C";
  Compartment_t  *c = Model_createCompartment(m);

  Compartment_setId   ( c, sid );
  Compartment_setSize ( c, 1.2 ); 
  Compartment_setUnits( c, "volume");

  fail_unless(Model_getNumUnitDefinitions(m) == 0);
  
  fail_unless( SBMLDocument_setLevelAndVersion(d, 3, 1) == 1, NULL);


  fail_unless(Model_getNumUnitDefinitions(m) == 2);

  UnitDefinition_t *ud = Model_getUnitDefinition(m, 0);

  fail_unless (ud != NULL);
  fail_unless (!strcmp(UnitDefinition_getId( ud), "volume"));
  fail_unless(UnitDefinition_getNumUnits(ud) == 1);

  Unit_t * u = UnitDefinition_getUnit(ud, 0);

  fail_unless(Unit_getKind(u) == UNIT_KIND_LITRE);
  fail_unless(Unit_getExponent(u) == 1);
  fail_unless(Unit_getMultiplier(u) == 1);
  fail_unless(Unit_getScale(u) == 0);

  ud = Model_getUnitDefinition(m, 1);

  fail_unless (ud != NULL);
  fail_unless (!strcmp(UnitDefinition_getId( ud), "time"));
  fail_unless(UnitDefinition_getNumUnits(ud) == 1);
  
  u = UnitDefinition_getUnit(ud, 0);

  fail_unless(Unit_getKind(u) == UNIT_KIND_SECOND);
  fail_unless(Unit_getExponent(u) == 1);
  fail_unless(Unit_getMultiplier(u) == 1);
  fail_unless(Unit_getScale(u) == 0);

  fail_unless(!strcmp(Model_getTimeUnits(m), "time"));

  SBMLDocument_free(d);
}
예제 #2
0
END_TEST


START_TEST (test_L3_Unit_multiplier)
{
  double multiplier = 0.2;

  fail_unless( !Unit_isSetMultiplier(U));
  fail_unless( isnan(Unit_getMultiplier(U)));
  
  Unit_setMultiplier(U, multiplier);

  fail_unless( Unit_getMultiplier(U) == multiplier );
  fail_unless( Unit_isSetMultiplier(U) );
}
예제 #3
0
파일: TestUnit.c 프로젝트: sn248/Rcppsbml
END_TEST


START_TEST (test_Unit_set_get_unset)
{
  Unit_t *u = Unit_create(2, 4);

  // defaults
  fail_unless( Unit_getKind      (u) == UNIT_KIND_INVALID );
  fail_unless( Unit_getExponent  (u) == 1   );
  fail_unless( Unit_isSetExponent(u) );
  fail_unless( Unit_getScale     (u) == 0   );
  fail_unless( Unit_isSetScale(u) );
  fail_unless( Unit_getMultiplier(u) == 1.0 );
  fail_unless( Unit_isSetMultiplier(u) );
  fail_unless( !Unit_isSetKind(u) );

  Unit_setKind(u, UNIT_KIND_WATT);
  fail_unless( Unit_getKind      (u) == UNIT_KIND_WATT );

  Unit_setExponent(u, 3);
  fail_unless( Unit_getExponent  (u) == 3   );

  Unit_setScale(u, 4);
  fail_unless( Unit_getScale     (u) == 4  );

  Unit_setMultiplier(u, 3.2);
  fail_unless( Unit_getMultiplier(u) == 3.2 );

  fail_unless( Unit_unsetKind(u) == LIBSBML_OPERATION_SUCCESS);

  fail_unless( Unit_unsetExponent(u) == LIBSBML_UNEXPECTED_ATTRIBUTE);

  fail_unless( Unit_unsetScale(u) == LIBSBML_UNEXPECTED_ATTRIBUTE);

  fail_unless( Unit_unsetMultiplier(u) == LIBSBML_UNEXPECTED_ATTRIBUTE);

  fail_unless( Unit_getKind      (u) == UNIT_KIND_INVALID );
  fail_unless( Unit_getExponent  (u) == 1   );
  fail_unless( Unit_isSetExponent(u) );
  fail_unless( Unit_getScale     (u) == 0   );
  fail_unless( Unit_isSetScale(u) );
  fail_unless( Unit_getMultiplier(u) == 1.0 );
  fail_unless( Unit_isSetMultiplier(u) );
  fail_unless( !Unit_isSetKind(u) );

  Unit_free(u);
}
END_TEST


START_TEST (test_Unit_setMultiplier1)
{
  int i = Unit_setMultiplier(U, 2);

  fail_unless( i == LIBSBML_UNEXPECTED_ATTRIBUTE );
  fail_unless( Unit_getMultiplier(U) == 2 );
}
예제 #5
0
파일: TestUnit.c 프로젝트: sn248/Rcppsbml
END_TEST


START_TEST (test_Unit_unset)
{
  Unit_t *u = Unit_create(2, 4);


  Unit_setKind(u, UNIT_KIND_WATT);
  Unit_setExponent(u, 3);
  Unit_setScale(u, 4);
  Unit_setMultiplier(u, 3.2);

  fail_unless( Unit_getKind      (u) == UNIT_KIND_WATT );
  fail_unless( Unit_getExponent  (u) == 3   );
  fail_unless( Unit_getScale     (u) == 4  );
  fail_unless( Unit_getMultiplier(u) == 3.2 );

  fail_unless (Unit_isSetKind(u) == 1);
  fail_unless (Unit_isSetExponent(u) == 1);
  fail_unless (Unit_isSetScale(u) == 1);
  fail_unless (Unit_isSetMultiplier(u) == 1);
  fail_unless (Unit_isSetOffset(u) == 0);

  Unit_unsetKind(u);
  Unit_unsetExponent(u);
  Unit_unsetScale(u);
  Unit_unsetMultiplier(u);

  fail_unless (Unit_isSetKind(u) == 0);
  fail_unless (Unit_isSetExponent(u) == 1);
  fail_unless (Unit_isSetScale(u) == 1);
  fail_unless (Unit_isSetMultiplier(u) == 1);
  fail_unless (Unit_isSetOffset(u) == 0);

  fail_unless( Unit_getKind      (u) == UNIT_KIND_INVALID );
  fail_unless( Unit_getExponent  (u) == 1   );
  fail_unless( Unit_getScale     (u) == 0  );
  fail_unless( Unit_getMultiplier(u) == 1.0 );

  Unit_free(u);
}
END_TEST


START_TEST (test_Unit_setMultiplier2)
{
  Unit_t *c = 
    Unit_create(2, 2);

  int i = Unit_setMultiplier(c, 4);

  fail_unless( i == LIBSBML_OPERATION_SUCCESS );
  fail_unless( Unit_getMultiplier(c) == 4 );

  Unit_free(c);
}
END_TEST


START_TEST (test_Unit_removeScale)
{
  int i = Unit_setScale(U, 2);

  fail_unless( i == LIBSBML_OPERATION_SUCCESS );
  fail_unless( Unit_getScale(U) == 2 );

  i = Unit_removeScale(U);

  fail_unless( i == LIBSBML_OPERATION_SUCCESS );
  fail_unless( Unit_getScale(U) == 0 );
  fail_unless( Unit_getMultiplier(U) == 100);
}
예제 #8
0
END_TEST


START_TEST (test_L3_Unit_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);

  Unit_t *u = 
    Unit_createWithNS (sbmlns);


  fail_unless( SBase_getTypeCode  ((SBase_t *) u) == SBML_UNIT );
  fail_unless( SBase_getMetaId    ((SBase_t *) u) == NULL );
  fail_unless( SBase_getNotes     ((SBase_t *) u) == NULL );
  fail_unless( SBase_getAnnotation((SBase_t *) u) == NULL );

  fail_unless( SBase_getLevel       ((SBase_t *) u) == 3 );
  fail_unless( SBase_getVersion     ((SBase_t *) u) == 1 );

  fail_unless( Unit_getNamespaces     (u) != NULL );
  fail_unless( XMLNamespaces_getLength(Unit_getNamespaces(u)) == 2 );


  fail_unless( Unit_getKind     (u) == UNIT_KIND_INVALID );
  fail_unless( isnan(Unit_getExponentAsDouble (u)) );
  fail_unless( isnan(Unit_getMultiplier (u)) );
//  fail_unless( isnan((double)(Unit_getScale (u))) );

  fail_unless( !Unit_isSetKind     (u) );
  fail_unless( !Unit_isSetExponent (u) );
  fail_unless( !Unit_isSetMultiplier (u) );
  fail_unless( !Unit_isSetScale (u) );

  Unit_free(u);
}