public void setUp()
 {
     C = new  Constraint(2,4);
       if (C == null);
       {
       }
 }
 public void test_Constraint()
 {
     Constraint c = new Constraint(2,4);
       assertEquals( false, (c.hasRequiredElements()) );
       c.setMath(libsbml.parseFormula("a+b"));
       assertEquals( true, c.hasRequiredElements() );
       c = null;
 }
Esempio n. 3
0
 public void test_Constraint_createWithNS()
 {
     XMLNamespaces xmlns = new  XMLNamespaces();
       xmlns.add( "http://www.sbml.org", "testsbml");
       SBMLNamespaces sbmlns = new  SBMLNamespaces(2,2);
       sbmlns.addNamespaces(xmlns);
       Constraint object1 = new  Constraint(sbmlns);
       assertTrue( object1.getTypeCode() == libsbml.SBML_CONSTRAINT );
       assertTrue( object1.getMetaId() == "" );
       assertTrue( object1.getNotes() == null );
       assertTrue( object1.getAnnotation() == null );
       assertTrue( object1.getLevel() == 2 );
       assertTrue( object1.getVersion() == 2 );
       assertTrue( object1.getNamespaces() != null );
       assertTrue( object1.getNamespaces().getLength() == 2 );
       object1 = null;
 }
        public void test_Constraint_constructor()
        {
            SBase s;

              try
              {
            s = new Constraint(2,2);
            s = new Constraint(2,3);
            s = new Constraint(2,4);
            s = new Constraint(3,1);
            s = new Constraint(SN22);
            s = new Constraint(SN23);
            s = new Constraint(SN24);
            s = new Constraint(SN31);
              }
              catch (SBMLConstructorException e)
              {
             s = null;
              }
              assertTrue(s != null);

              string msg = "";

              try
              {
            s = new Constraint(1,1);
              }
              catch (SBMLConstructorException e)
              {
             msg = e.Message;
              }
              assertTrue(msg == ErrMsg);

              msg = "";
              try
              {
            s = new Constraint(1,2);
              }
              catch (SBMLConstructorException e)
              {
             msg = e.Message;
              }
              assertTrue(msg == ErrMsg);

              msg = "";
              try
              {
            s = new Constraint(2,1);
              }
              catch (SBMLConstructorException e)
              {
             msg = e.Message;
              }
              assertTrue(msg == ErrMsg);

              msg = "";
              try
              {
            s = new Constraint(9,9);
              }
              catch (SBMLConstructorException e)
              {
             msg = e.Message;
              }
              assertTrue(msg == ErrMsg);

              msg = "";
              try
              {
            s = new Constraint(SN11);
              }
              catch (SBMLConstructorException e)
              {
             msg = e.Message;
              }
              assertTrue(msg == ErrMsg);

              msg = "";
              try
              {
            s = new Constraint(SN12);
              }
              catch (SBMLConstructorException e)
              {
             msg = e.Message;
              }
              assertTrue(msg == ErrMsg);

              msg = "";
              try
              {
            s = new Constraint(SN21);
              }
              catch (SBMLConstructorException e)
              {
             msg = e.Message;
              }
              assertTrue(msg == ErrMsg);

              msg = "";
              try
              {
            s = new Constraint(SN99);
              }
              catch (SBMLConstructorException e)
              {
             msg = e.Message;
              }
              assertTrue(msg == ErrMsg);
        }
Esempio n. 5
0
 /**
    * Adds a copy of the given Constraint object to this Model.
    *
    * @param c the Constraint object to add
    *
    *
  * @return integer value indicating success/failure of the
  * function.  @if clike The value is drawn from the
  * enumeration #OperationReturnValues_t. @endif The possible values
  * returned by this function are:
  * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink
    * @li @link libsbml#LIBSBML_LEVEL_MISMATCH LIBSBML_LEVEL_MISMATCH@endlink
    * @li @link libsbml#LIBSBML_VERSION_MISMATCH LIBSBML_VERSION_MISMATCH@endlink
    * @li @link libsbml#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT@endlink
    * @li @link 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 createConstraint()
    */
 public int addConstraint(Constraint c)
 {
     int ret = libsbmlPINVOKE.Model_addConstraint(swigCPtr, Constraint.getCPtr(c));
     return ret;
 }
Esempio n. 6
0
        internal static HandleRef getCPtrAndDisown(Constraint obj)
        {
            HandleRef ptr = new HandleRef(null, IntPtr.Zero);

            if (obj != null)
            {
            ptr             = obj.swigCPtr;
            obj.swigCMemOwn = false;
            }

            return ptr;
        }
Esempio n. 7
0
 internal static HandleRef getCPtr(Constraint obj)
 {
     return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
Esempio n. 8
0
 /**
    * Copy constructor; creates a copy of this Constraint.
    *
    * @param orig the object to copy.
    */
 public Constraint(Constraint orig)
     : this(libsbmlPINVOKE.new_Constraint__SWIG_2(Constraint.getCPtr(orig)), true)
 {
     if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve();
 }
 public void test_Constraint_parent_add()
 {
     Constraint ct = new Constraint(2,4);
       Model m = new Model(2,4);
       ct.setMath(libsbml.parseFormula("a-k"));
       m.addConstraint(ct);
       ct = null;
       ListOf lo = m.getListOfConstraints();
       assertTrue( lo == m.getConstraint(0).getParentSBMLObject() );
       assertTrue( m == lo.getParentSBMLObject() );
 }
Esempio n. 10
0
 public void test_Constraint_ancestor_add()
 {
     Constraint ct = new Constraint(2,4);
       Model m = new Model(2,4);
       ct.setMath(libsbml.parseFormula("k+k"));
       m.addConstraint(ct);
       ct = null;
       ListOf lo = m.getListOfConstraints();
       Constraint obj = m.getConstraint(0);
       assertTrue( obj.getAncestorOfType(libsbml.SBML_MODEL) == m );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_LIST_OF) == lo );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_DOCUMENT) == null );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_EVENT) == null );
 }
Esempio n. 11
0
 public void test_Model_addConstraint2()
 {
     Model m = new  Model(2,2);
       Constraint c = new  Constraint(2,3);
       c.setMath(libsbml.parseFormula("a+b"));
       int i = m.addConstraint(c);
       assertTrue( i == libsbml.LIBSBML_VERSION_MISMATCH );
       assertTrue( m.getNumConstraints() == 0 );
       c = null;
       m = null;
 }
Esempio n. 12
0
 public void test_Model_addConstraint1()
 {
     Model m = new  Model(2,2);
       Constraint c = new  Constraint(2,2);
       int i = m.addConstraint(c);
       assertTrue( i == libsbml.LIBSBML_INVALID_OBJECT );
       c.setMath(libsbml.parseFormula("a+b"));
       i = m.addConstraint(c);
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       assertTrue( m.getNumConstraints() == 1 );
       c = null;
       m = null;
 }
 public void tearDown()
 {
     C = null;
 }
 public void test_internal_consistency_check_99909()
 {
     SBMLDocument d = new SBMLDocument(2,4);
       long errors;
       Constraint ct = new Constraint(2,4);
       Model m = d.createModel();
       d.setLevelAndVersion(2,1,false);
       m.addConstraint(ct);
       errors = d.checkInternalConsistency();
       assertTrue( errors == 0 );
       d = null;
 }
 public void test_Constraint()
 {
     Constraint c = new Constraint(2,4);
       assertEquals( true, c.hasRequiredAttributes() );
       c = null;
 }
Esempio n. 16
0
 public void test_Constraint_copyConstructor()
 {
     Constraint o1 = new Constraint(2,4);
       o1.setMetaId("c");
       assertTrue( o1.getMetaId() ==  "c" );
       XMLNode text = XMLNode.convertStringToXMLNode(" Some text ");
       XMLTriple triple = new XMLTriple("p", "http://www.w3.org/1999/xhtml", "");
       XMLAttributes att = new XMLAttributes();
       XMLNamespaces xmlns = new XMLNamespaces();
       xmlns.add("http://www.w3.org/1999/xhtml");
       XMLNode p = new XMLNode(triple,att,xmlns);
       p.addChild(text);
       XMLTriple triple1 = new XMLTriple("message", "", "");
       XMLAttributes att1 = new XMLAttributes();
       XMLNode message = new XMLNode(triple1,att1);
       message.addChild(p);
       ASTNode math = new ASTNode(libsbml.AST_CONSTANT_PI);
       o1.setMath(math);
       o1.setMessage(message);
       math = null;
       message = null;
       XMLNode msg;
       assertTrue( o1.getMath() != null );
       msg = o1.getMessage();
       assertTrue( msg != null );
       Constraint o2 = new Constraint(o1);
       assertTrue( o2.getMetaId() ==  "c" );
       assertTrue( o2.getMath() != null );
       msg = o2.getMessage();
       assertTrue( msg != null );
       assertTrue( o2.getParentSBMLObject() == o1.getParentSBMLObject() );
       o2 = null;
       o1 = null;
 }