Beispiel #1
0
END_TEST


START_TEST (test_L3_Unit_kind)
{
  char *kind = "mole";


  fail_unless( !Unit_isSetKind(U) );
  
  Unit_setKind(U, UnitKind_forName(kind));

  fail_unless( Unit_getKind(U) == UNIT_KIND_MOLE );
  fail_unless( Unit_isSetKind(U) );
}
Beispiel #2
0
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_setKind2)
{
  int i = Unit_setKind(U, UnitKind_forName("litre"));

  fail_unless( i == LIBSBML_OPERATION_SUCCESS );
  fail_unless( Unit_isSetKind(U) );
}
Beispiel #4
0
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);
}
Beispiel #5
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);
}
Beispiel #6
0
END_TEST


START_TEST (test_Unit_isXXX)
{
  fail_unless( !Unit_isSetKind(U) );

  Unit_setKind(U, UNIT_KIND_AMPERE);
  fail_unless( Unit_isAmpere(U) );

  Unit_setKind(U, UNIT_KIND_BECQUEREL);
  fail_unless( Unit_isBecquerel(U) );

  Unit_setKind(U, UNIT_KIND_CANDELA);
  fail_unless( Unit_isCandela(U) );

  /* since the Unit is the default level and version
   * celsius is no longer a valid unit
   * and setKind will fail
   */
/*  Unit_setKind(U, UNIT_KIND_CELSIUS);
  fail_unless( Unit_isCelsius(U) );
*/
  Unit_setKind(U, UNIT_KIND_COULOMB);
  fail_unless( Unit_isCoulomb(U) );

  Unit_setKind(U, UNIT_KIND_DIMENSIONLESS);
  fail_unless( Unit_isDimensionless(U) );

  Unit_setKind(U, UNIT_KIND_FARAD);
  fail_unless( Unit_isFarad(U) );

  Unit_setKind(U, UNIT_KIND_GRAM);
  fail_unless( Unit_isGram(U) );

  Unit_setKind(U, UNIT_KIND_GRAY);
  fail_unless( Unit_isGray(U) );

  Unit_setKind(U, UNIT_KIND_HENRY);
  fail_unless( Unit_isHenry(U) );

  Unit_setKind(U, UNIT_KIND_HERTZ);
  fail_unless( Unit_isHertz(U) );

  Unit_setKind(U, UNIT_KIND_ITEM);
  fail_unless( Unit_isItem(U) );

  Unit_setKind(U, UNIT_KIND_JOULE);
  fail_unless( Unit_isJoule(U) );

  Unit_setKind(U, UNIT_KIND_KATAL);
  fail_unless( Unit_isKatal(U) );

  Unit_setKind(U, UNIT_KIND_KELVIN);
  fail_unless( Unit_isKelvin(U) );

  Unit_setKind(U, UNIT_KIND_KILOGRAM);
  fail_unless( Unit_isKilogram(U) );

  Unit_setKind(U, UNIT_KIND_LITRE);
  fail_unless( Unit_isLitre(U) );

  Unit_setKind(U, UNIT_KIND_LUMEN);
  fail_unless( Unit_isLumen(U) );

  Unit_setKind(U, UNIT_KIND_LUX);
  fail_unless( Unit_isLux(U) );

  Unit_setKind(U, UNIT_KIND_METRE);
  fail_unless( Unit_isMetre(U) );

  Unit_setKind(U, UNIT_KIND_MOLE);
  fail_unless( Unit_isMole(U) );

  Unit_setKind(U, UNIT_KIND_NEWTON);
  fail_unless( Unit_isNewton(U) );

  Unit_setKind(U, UNIT_KIND_OHM);
  fail_unless( Unit_isOhm(U) );

  Unit_setKind(U, UNIT_KIND_PASCAL);
  fail_unless( Unit_isPascal(U) );

  Unit_setKind(U, UNIT_KIND_RADIAN);
  fail_unless( Unit_isRadian(U) );

  Unit_setKind(U, UNIT_KIND_SECOND);
  fail_unless( Unit_isSecond(U) );

  Unit_setKind(U, UNIT_KIND_SIEMENS);
  fail_unless( Unit_isSiemens(U) );

  Unit_setKind(U, UNIT_KIND_SIEVERT);
  fail_unless( Unit_isSievert(U) );

  Unit_setKind(U, UNIT_KIND_STERADIAN);
  fail_unless( Unit_isSteradian(U) );

  Unit_setKind(U, UNIT_KIND_TESLA);
  fail_unless( Unit_isTesla(U) );

  Unit_setKind(U, UNIT_KIND_VOLT);
  fail_unless( Unit_isVolt(U) );

  Unit_setKind(U, UNIT_KIND_WATT);
  fail_unless( Unit_isWatt(U) );

  Unit_setKind(U, UNIT_KIND_WEBER);
  fail_unless( Unit_isWeber(U) );
}