public void setUp() { U = new Unit(2,4); if (U == null); { } }
public void test_UnitDefinition_addUnit() { Unit u = new Unit(2,4); u.setKind(libsbml.UNIT_KIND_MOLE); UD.addUnit(u); assertTrue( UD.getNumUnits() == 1 ); u = null; }
public void test_UnitDefinition_addUnit2() { UnitDefinition m = new UnitDefinition(2,2); Unit p = new Unit(2,1); p.setKind(libsbml.UNIT_KIND_MOLE); int i = m.addUnit(p); assertTrue( i == libsbml.LIBSBML_VERSION_MISMATCH ); assertTrue( m.getNumUnits() == 0 ); p = null; m = null; }
public void test_UnitDefinition_addUnit1() { UnitDefinition m = new UnitDefinition(2,2); Unit p = new Unit(2,2); int i = m.addUnit(p); assertTrue( i == libsbml.LIBSBML_INVALID_OBJECT ); p.setKind(libsbml.UNIT_KIND_MOLE); i = m.addUnit(p); assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS ); assertTrue( m.getNumUnits() == 1 ); p = null; m = null; }
public void test_Unit_createWithNS() { XMLNamespaces xmlns = new XMLNamespaces(); xmlns.add( "http://www.sbml.org", "testsbml"); SBMLNamespaces sbmlns = new SBMLNamespaces(2,1); sbmlns.addNamespaces(xmlns); Unit object1 = new Unit(sbmlns); assertTrue( object1.getTypeCode() == libsbml.SBML_UNIT ); assertTrue( object1.getMetaId() == "" ); assertTrue( object1.getNotes() == null ); assertTrue( object1.getAnnotation() == null ); assertTrue( object1.getLevel() == 2 ); assertTrue( object1.getVersion() == 1 ); assertTrue( object1.getNamespaces() != null ); assertTrue( object1.getNamespaces().getLength() == 2 ); object1 = null; }
public void test_Unit_set_get() { Unit u = new Unit(2,4); assertTrue( u.getKind() == libsbml.UNIT_KIND_INVALID ); assertTrue( u.getExponent() == 1 ); assertTrue( u.getScale() == 0 ); assertTrue( u.getMultiplier() == 1.0 ); assertEquals( false, u.isSetKind() ); u.setKind(libsbml.UNIT_KIND_WATT); assertTrue( u.getKind() == libsbml.UNIT_KIND_WATT ); u.setExponent(3); assertTrue( u.getExponent() == 3 ); u.setScale(4); assertTrue( u.getScale() == 4 ); u.setMultiplier(3.2); assertTrue( u.getMultiplier() == 3.2 ); u = null; }
/** * Copy constructor; creates a copy of this Unit. * * @param orig the object to copy. * * @throws SBMLConstructorException * Thrown if the argument @p orig is @c null. */ public Unit(Unit orig) : this(libsbmlPINVOKE.new_Unit__SWIG_2(Unit.getCPtr(orig)), true) { if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); }
public void test_L3_Unit_createWithNS() { XMLNamespaces xmlns = new XMLNamespaces(); xmlns.add( "http://www.sbml.org", "testsbml"); SBMLNamespaces sbmlns = new SBMLNamespaces(3,1); sbmlns.addNamespaces(xmlns); Unit u = new Unit(sbmlns); assertTrue( u.getTypeCode() == libsbml.SBML_UNIT ); assertTrue( u.getMetaId() == "" ); assertTrue( u.getNotes() == null ); assertTrue( u.getAnnotation() == null ); assertTrue( u.getLevel() == 3 ); assertTrue( u.getVersion() == 1 ); assertTrue( u.getNamespaces() != null ); assertTrue( u.getNamespaces().getLength() == 2 ); assertTrue( u.getKind() == libsbml.UNIT_KIND_INVALID ); assertEquals( true, isnan(u.getExponentAsDouble()) ); assertEquals( true, isnan(u.getMultiplier()) ); assertEquals( false, u.isSetKind() ); assertEquals( false, u.isSetExponent() ); assertEquals( false, u.isSetMultiplier() ); assertEquals( false, u.isSetScale() ); u = null; }
public void test_Unit_ancestor_add() { UnitDefinition ud = new UnitDefinition(2,4); Unit u = new Unit(2,4); u.setKind(libsbml.UNIT_KIND_MOLE); ud.addUnit(u); u = null; assertTrue( ud.getNumUnits() == 1 ); ListOf lo = ud.getListOfUnits(); Unit obj = ud.getUnit(0); assertTrue( obj.getAncestorOfType(libsbml.SBML_UNIT_DEFINITION) == ud ); assertTrue( obj.getAncestorOfType(libsbml.SBML_LIST_OF) == lo ); assertTrue( obj.getAncestorOfType(libsbml.SBML_DOCUMENT) == null ); assertTrue( obj.getAncestorOfType(libsbml.SBML_COMPARTMENT) == null ); ud = null; }
public void test_Unit() { Unit u = new Unit(2,4); assertEquals( true, u.hasRequiredElements() ); u = null; }
public void test_Unit_setMultiplier2() { Unit c = new Unit(2,2); int i = c.setMultiplier(4); assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS ); assertTrue( c.getMultiplier() == 4 ); c = null; }
public void test_UnitDefinition_isVariantOfSubstancePerTime_3() { UnitDefinition ud = new UnitDefinition(2,2); Unit dim = new Unit(2,2); dim.setKind(libsbml.UnitKind_forName("dimensionless")); Unit perTime = ud.createUnit(); perTime.setKind(libsbml.UnitKind_forName("second")); perTime.setExponent(-1); Unit u = ud.createUnit(); assertEquals( false, ud.isVariantOfSubstancePerTime() ); u.setKind(libsbml.UNIT_KIND_GRAM); u.setExponent(1); assertEquals( true, ud.isVariantOfSubstancePerTime() ); u.setScale(-1); perTime.setScale(-1); assertEquals( true, ud.isVariantOfSubstancePerTime() ); u.setMultiplier(2); assertEquals( true, ud.isVariantOfSubstancePerTime() ); u.setOffset(3); assertEquals( true, ud.isVariantOfSubstancePerTime() ); u.setExponent(-3); assertEquals( false, ud.isVariantOfSubstancePerTime() ); u.setExponent(1); perTime.setExponent(-3); assertEquals( false, ud.isVariantOfSubstancePerTime() ); perTime.setExponent(-1); ud.addUnit(dim); assertEquals( true, ud.isVariantOfSubstancePerTime() ); ud = null; dim = null; }
public void test_Unit_setOffset2() { Unit U1 = new Unit(2,1); int i = U1.setOffset(2.0); assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS ); assertTrue( U1.getOffset() == 2 ); }
public void tearDown() { U = null; }
public void test_Unit_parent_add() { UnitDefinition ud = new UnitDefinition(2,4); Unit u = new Unit(2,4); u.setKind(libsbml.UNIT_KIND_MOLE); ud.addUnit(u); u = null; assertTrue( ud.getNumUnits() == 1 ); ListOf lo = ud.getListOfUnits(); assertTrue( lo == ud.getUnit(0).getParentSBMLObject() ); assertTrue( ud == lo.getParentSBMLObject() ); ud = null; }
internal static HandleRef getCPtrAndDisown(Unit obj) { HandleRef ptr = new HandleRef(null, IntPtr.Zero); if (obj != null) { ptr = obj.swigCPtr; obj.swigCMemOwn = false; } return ptr; }
internal static HandleRef getCPtr(Unit obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; }
public void test_internal_consistency_check_99925() { SBMLDocument d = new SBMLDocument(2,4); long errors; Unit u = new Unit(2,4); d.setLevelAndVersion(1,2,false); Model m = d.createModel(); Compartment c = m.createCompartment(); c.setId("cc"); UnitDefinition ud = m.createUnitDefinition(); ud.setId("ud"); u.setKind(libsbml.UNIT_KIND_MOLE); u.setOffset(9); ud.addUnit(u); errors = d.checkInternalConsistency(); assertTrue( errors == 0 ); d = null; }
public void test_SBMLDocument_setLevelAndVersion_Error() { SBMLDocument d = new SBMLDocument(); d.setLevelAndVersion(2,1,true); Model m1 = new Model(2,1); Unit u = new Unit(2,1); u.setKind(libsbml.UnitKind_forName("mole")); u.setOffset(3.2); UnitDefinition ud = new UnitDefinition(2,1); ud.setId( "ud"); ud.addUnit(u); m1.addUnitDefinition(ud); d.setModel(m1); assertTrue( d.setLevelAndVersion(2,2,true) == false ); assertTrue( d.setLevelAndVersion(2,3,true) == false ); assertTrue( d.setLevelAndVersion(1,2,true) == false ); assertTrue( d.setLevelAndVersion(1,1,true) == false ); d = null; }
public void test_Unit() { Unit u = new Unit(2,4); assertEquals( false, (u.hasRequiredAttributes()) ); u.setKind(libsbml.UNIT_KIND_MOLE); assertEquals( true, u.hasRequiredAttributes() ); u = null; }
/** * Predicate returning @c true if two * Unit objects are identical. * * Two Unit objects are considered to be @em identical if they match in * all attributes. (Contrast this to the method areEquivalent(@if java * Unit u1, %Unit u2@endif), which compares Unit objects only with respect * to certain attributes.) * * @param unit1 the first Unit object to compare * @param unit2 the second Unit object to compare * * @return @c true if all the attributes of unit1 are identical * to the attributes of unit2, @c false otherwise. * * * * @if python @note Because this is a static method on a class, the Python * language interface for libSBML will contain two variants. One will be the * expected, normal static method on the class (i.e., a regular * <em>methodName</em>), and the other will be a standalone top-level * function with the name <em>ClassName_methodName()</em>. This is merely an * artifact of how the language interfaces are created in libSBML. The * methods are functionally identical. @endif * * * * @see @if clike areEquivalent() @else Unit::areEquivalent(Unit u1, %Unit u2) @endif */ public static bool areIdentical(Unit unit1, Unit unit2) { bool ret = libsbmlPINVOKE.Unit_areIdentical(Unit.getCPtr(unit1), Unit.getCPtr(unit2)); return ret; }
/** * Returns a UnitDefinition object containing the given @p unit converted * to the appropriate SI unit. * * This method exists because some units can be expressed in terms of * others when the same physical dimension is involved. For example, one * hertz is identical to 1 sec<sup>-1</sup>, one litre is equivalent * to 1 cubic decametre, and so on. * * @param unit the Unit object to convert to SI * * @return a UnitDefinition object containing the SI unit. * * * * @if python @note Because this is a static method on a class, the Python * language interface for libSBML will contain two variants. One will be the * expected, normal static method on the class (i.e., a regular * <em>methodName</em>), and the other will be a standalone top-level * function with the name <em>ClassName_methodName()</em>. This is merely an * artifact of how the language interfaces are created in libSBML. The * methods are functionally identical. @endif * * * * @see @if clike merge() @else Unit::merge(Unit u1, Unit u2) @endif */ public static UnitDefinition convertToSI(Unit unit) { IntPtr cPtr = libsbmlPINVOKE.Unit_convertToSI(Unit.getCPtr(unit)); UnitDefinition ret = (cPtr == IntPtr.Zero) ? null : new UnitDefinition(cPtr, true); return ret; }
public void test_UnitDefinition_getUnit() { Unit mole = new Unit(2,4); Unit litre = new Unit(2,4); Unit second = new Unit(2,4); mole.setKind(libsbml.UnitKind_forName("mole")); litre.setKind(libsbml.UnitKind_forName("litre")); second.setKind(libsbml.UnitKind_forName("second")); mole.setScale(-3); litre.setExponent(-1); second.setExponent(-1); UD.addUnit(mole); UD.addUnit(litre); UD.addUnit(second); mole = null; litre = null; second = null; assertTrue( UD.getNumUnits() == 3 ); mole = UD.getUnit(0); litre = UD.getUnit(1); second = UD.getUnit(2); assertTrue( mole.getKind() == libsbml.UNIT_KIND_MOLE ); assertTrue( litre.getKind() == libsbml.UNIT_KIND_LITRE ); assertTrue( second.getKind() == libsbml.UNIT_KIND_SECOND ); assertTrue( mole.getScale() == -3 ); assertTrue( litre.getExponent() == -1 ); assertTrue( second.getExponent() == -1 ); }
/** * Merges two Unit objects with the same 'kind' attribute value into a * single Unit. * * For example, the following, * @verbatim <unit kind='metre' exponent='2'/> <unit kind='metre' exponent='1'/> @endverbatim * would be merged to become * @verbatim <unit kind='metre' exponent='3'/> @endverbatim * * @param unit1 the first Unit object; the result of the operation is * left as a new version of this unit, modified in-place. Not modified if * the two units have different kinds. * * @param unit2 the second Unit object to merge with the first * * * * @if python @note Because this is a static method on a class, the Python * language interface for libSBML will contain two variants. One will be the * expected, normal static method on the class (i.e., a regular * <em>methodName</em>), and the other will be a standalone top-level * function with the name <em>ClassName_methodName()</em>. This is merely an * artifact of how the language interfaces are created in libSBML. The * methods are functionally identical. @endif * * * * @see @if clike convertToSI() @else Unit::convertToSI(Unit u) @endif * @see @if clike removeScale() @else Unit::removeScale(Unit u) @endif */ public static void merge(Unit unit1, Unit unit2) { libsbmlPINVOKE.Unit_merge(Unit.getCPtr(unit1), Unit.getCPtr(unit2)); }
public void test_UnitDefinition_isVariantOfVolume_2() { Unit dim = new Unit(2,4); dim.setKind(libsbml.UnitKind_forName("dimensionless")); Unit u = UD.createUnit(); assertEquals( false, UD.isVariantOfVolume() ); u.setKind(libsbml.UNIT_KIND_METRE); u.setExponent(3); assertEquals( true, UD.isVariantOfVolume() ); u.setScale(100); assertEquals( true, UD.isVariantOfVolume() ); u.setMultiplier(5); assertEquals( true, UD.isVariantOfVolume() ); u.setOffset(-5); assertEquals( true, UD.isVariantOfVolume() ); u.setExponent(2); assertEquals( false, UD.isVariantOfVolume() ); u.setExponent(3); UD.addUnit(dim); assertEquals( true, UD.isVariantOfVolume() ); }
/** * Manipulates the attributes of the Unit to express the unit with the * value of the scale attribute reduced to zero. * * For example, 1 millimetre can be expressed as a Unit with kind=@c * 'metre' multiplier=@c '1' scale=@c '-3' exponent=@c '1'. It can also be * expressed as a Unit with kind=@c 'metre' * multiplier=<code>'0.001'</code> scale=@c '0' exponent=@c '1'. * * @param unit the Unit object to manipulate. * * @return integer value indicating success/failure of the function. The * possible values returned by this function are: * @li @link libsbmlcs#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink * * * * @if python @note Because this is a static method on a class, the Python * language interface for libSBML will contain two variants. One will be the * expected, normal static method on the class (i.e., a regular * <em>methodName</em>), and the other will be a standalone top-level * function with the name <em>ClassName_methodName()</em>. This is merely an * artifact of how the language interfaces are created in libSBML. The * methods are functionally identical. @endif * * * * @see @if clike convertToSI() @else Unit::convertToSI(Unit u) @endif * @see @if clike merge() @else Unit::merge(Unit u1, Unit u2) @endif */ public static int removeScale(Unit unit) { int ret = libsbmlPINVOKE.Unit_removeScale(Unit.getCPtr(unit)); return ret; }
/** * Adds a copy of the given Unit to this UnitDefinition. * * @param u the Unit instance to add to this UnitDefinition. * * @return integer value indicating success/failure of the * function. The possible values * returned by this function are: * @li @link libsbmlcs.libsbml.LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS @endlink * @li @link libsbmlcs.libsbml.LIBSBML_LEVEL_MISMATCH LIBSBML_LEVEL_MISMATCH @endlink * @li @link libsbmlcs.libsbml.LIBSBML_VERSION_MISMATCH LIBSBML_VERSION_MISMATCH @endlink * @li @link libsbmlcs.libsbml.LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT @endlink * @li @link libsbmlcs.libsbml.LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED @endlink * * * * @note This method should be used with some caution. The fact that this * method @em copies the object passed to it means that the caller will be * left holding a physically different object instance than the one contained * inside this object. Changes made to the original object instance (such as * resetting attribute values) will <em>not affect the instance in this * object</em>. In addition, the caller should make sure to free the * original object if it is no longer being used, or else a memory leak will * result. Please see other methods on this class (particularly a * corresponding method whose name begins with the word <code>create</code>) * for alternatives that do not lead to these issues. * * * * @see createUnit() */ public int addUnit(Unit u) { int ret = libsbmlPINVOKE.UnitDefinition_addUnit(swigCPtr, Unit.getCPtr(u)); return ret; }
public void test_L3_Unit_hasRequiredAttributes() { Unit u = new Unit(3,1); assertEquals( false, u.hasRequiredAttributes() ); u.setKind(libsbml.UNIT_KIND_MOLE); assertEquals( false, u.hasRequiredAttributes() ); u.setExponent(0); assertEquals( false, u.hasRequiredAttributes() ); u.setMultiplier(0.45); assertEquals( false, u.hasRequiredAttributes() ); u.setScale(2); assertEquals( true, u.hasRequiredAttributes() ); u = null; }
public void test_Unit_constructor() { SBase s; try { s = new Unit(1,1); s = new Unit(1,2); s = new Unit(2,1); s = new Unit(2,2); s = new Unit(2,3); s = new Unit(2,4); s = new Unit(3,1); s = new Unit(SN11); s = new Unit(SN12); s = new Unit(SN21); s = new Unit(SN22); s = new Unit(SN23); s = new Unit(SN24); s = new Unit(SN31); } catch (SBMLConstructorException e) { s = null; } assertTrue(s != null); string msg = ""; try { s = new Unit(9,9); } catch (SBMLConstructorException e) { msg = e.Message; } assertTrue(msg == ErrMsg); msg = ""; try { s = new Unit(SN99); } catch (SBMLConstructorException e) { msg = e.Message; } assertTrue(msg == ErrMsg); }
public void test_Unit_copyConstructor() { Unit o1 = new Unit(2,4); o1.setKind(libsbml.UNIT_KIND_MOLE); assertTrue( o1.getKind() == libsbml.UNIT_KIND_MOLE ); Unit o2 = new Unit(o1); assertTrue( o2.getKind() == libsbml.UNIT_KIND_MOLE ); assertTrue( o2.getParentSBMLObject() == o1.getParentSBMLObject() ); o2 = null; o1 = null; }