setValue() public method

public setValue ( double value ) : int
value double
return int
Esempio n. 1
0
 public void test_ASTNode_isSqrt()
 {
     ASTNode n = new  ASTNode();
       ASTNode c;
       n.setType(libsbml.AST_FUNCTION);
       assertTrue( n.isSqrt() == false );
       n.setType(libsbml.AST_FUNCTION_ROOT);
       assertTrue( n.isSqrt() == false );
       c = new  ASTNode();
       n.addChild(c);
       c.setValue(2);
       assertTrue( n.isSqrt() == false );
       n.addChild(new  ASTNode());
       assertTrue( n.isSqrt() == true );
       c.setValue(3);
       assertTrue( n.isSqrt() == false );
       n = null;
 }
Esempio n. 2
0
 public void test_ASTNode_setInteger()
 {
     ASTNode node = new  ASTNode();
       node.setName( "foo");
       assertTrue( node.getType() == libsbml.AST_NAME );
       assertTrue((  "foo" == node.getName() ));
       assertTrue( node.getCharacter() == '\0' );
       assertTrue( node.getInteger() == 0 );
       assertTrue( node.getReal() == 0 );
       assertTrue( node.getExponent() == 0 );
       assertTrue( node.getDenominator() == 1 );
       node.setValue(3.2);
       assertTrue( node.getType() == libsbml.AST_REAL );
       assertTrue( node.getInteger() == 0 );
       assertTrue( node.getName() == null );
       assertTrue( node.getCharacter() == '\0' );
       assertTrue( node.getReal() == 3.2 );
       assertTrue( node.getExponent() == 0 );
       assertTrue( node.getDenominator() == 1 );
       node.setValue(321);
       assertTrue( node.getType() == libsbml.AST_INTEGER );
       assertTrue( node.getInteger() == 321 );
       assertTrue( node.getName() == null );
       assertTrue( node.getCharacter() == '\0' );
       assertTrue( node.getReal() == 0 );
       assertTrue( node.getExponent() == 0 );
       assertTrue( node.getDenominator() == 1 );
       node = null;
 }
Esempio n. 3
0
 public void test_ASTNode_children()
 {
     ASTNode parent = new  ASTNode();
       ASTNode left = new  ASTNode();
       ASTNode right = new  ASTNode();
       ASTNode right2 = new  ASTNode();
       parent.setType(libsbml.AST_PLUS);
       left.setValue(1);
       right.setValue(2);
       right2.setValue(3);
       parent.addChild(left);
       parent.addChild(right);
       assertTrue( parent.getNumChildren() == 2 );
       assertTrue( left.getNumChildren() == 0 );
       assertTrue( right.getNumChildren() == 0 );
       assertTrue( parent.getLeftChild() == left );
       assertTrue( parent.getRightChild() == right );
       assertTrue( parent.getChild(0) == left );
       assertTrue( parent.getChild(1) == right );
       assertTrue( parent.getChild(2) == null );
       parent.addChild(right2);
       assertTrue( parent.getNumChildren() == 3 );
       assertTrue( left.getNumChildren() == 0 );
       assertTrue( right.getNumChildren() == 0 );
       assertTrue( right2.getNumChildren() == 0 );
       assertTrue( parent.getLeftChild() == left );
       assertTrue( parent.getRightChild() == right2 );
       assertTrue( parent.getChild(0) == left );
       assertTrue( parent.getChild(1) == right );
       assertTrue( parent.getChild(2) == right2 );
       assertTrue( parent.getChild(3) == null );
       parent = null;
 }
Esempio n. 4
0
 public void test_ASTNode_getReal()
 {
     ASTNode n = new  ASTNode();
       n.setType(libsbml.AST_REAL);
       n.setValue(1.6);
       assertTrue( n.getReal() == 1.6 );
       n.setType(libsbml.AST_REAL_E);
       n.setValue(12.3,3);
       double val = Math.Abs(n.getReal() - 12300.0);
       assertTrue( val < DBL_EPSILON );
       n.setType(libsbml.AST_RATIONAL);
       n.setValue(1,2);
       assertTrue( n.getReal() == 0.5 );
       n = null;
 }
Esempio n. 5
0
 public void test_ASTNode_units()
 {
     ASTNode n = new  ASTNode();
       n.setType(libsbml.AST_REAL);
       n.setValue(1.6);
       int i = n.setUnits( "mole");
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       assertTrue( n.isSetUnits() == true );
       assertTrue((  "mole" == n.getUnits() ));
       i = n.unsetUnits();
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       assertTrue( n.isSetUnits() == false );
       assertTrue((  "" == n.getUnits() ));
       i = n.setUnits( "1mole");
       assertTrue( i == libsbml.LIBSBML_INVALID_ATTRIBUTE_VALUE );
       assertTrue( n.isSetUnits() == false );
       n.setType(libsbml.AST_FUNCTION);
       i = n.setUnits( "mole");
       assertTrue( i == libsbml.LIBSBML_UNEXPECTED_ATTRIBUTE );
       assertTrue( n.isSetUnits() == false );
       assertTrue((  "" == n.getUnits() ));
       n = null;
 }
Esempio n. 6
0
 public void test_ASTNode_setReal()
 {
     ASTNode node = new  ASTNode();
       node.setName( "foo");
       assertTrue( node.getType() == libsbml.AST_NAME );
       node.setValue(32.1);
       assertTrue( node.getType() == libsbml.AST_REAL );
       assertTrue( node.getInteger() == 0 );
       assertTrue( node.getName() == null );
       assertTrue( node.getCharacter() == '\0' );
       assertTrue( node.getReal() == 32.1 );
       assertTrue( node.getExponent() == 0 );
       assertTrue( node.getDenominator() == 1 );
       assertTrue( node.getMantissa() == 32.1 );
       node.setValue(45,90);
       assertTrue( node.getType() == libsbml.AST_RATIONAL );
       assertTrue( node.getInteger() == 45 );
       assertTrue( node.getName() == null );
       assertTrue( node.getCharacter() == '\0' );
       assertTrue( node.getReal() == 0.5 );
       assertTrue( node.getExponent() == 0 );
       assertTrue( node.getDenominator() == 90 );
       assertTrue( node.getMantissa() == 0 );
       node.setValue(32.0,4);
       assertTrue( node.getType() == libsbml.AST_REAL_E );
       assertTrue( node.getInteger() == 0 );
       assertTrue( node.getName() == null );
       assertTrue( node.getCharacter() == '\0' );
       assertTrue( node.getReal() == 320000 );
       assertTrue( node.getExponent() == 4 );
       assertTrue( node.getDenominator() == 1 );
       assertTrue( node.getMantissa() == 32 );
       node = null;
 }
Esempio n. 7
0
 public void test_MathMLFormatter_constant_notanumber()
 {
     string expected = wrapMathML("  <notanumber/>\n");
       N = new ASTNode(libsbml.AST_REAL);
       N.setValue( util_NaN() );
       S = libsbml.writeMathMLToString(N);
       assertEquals( true, equals(expected,S) );
 }
Esempio n. 8
0
 public void test_MathMLFormatter_constant_infinity_neg()
 {
     string expected = wrapMathML("  <apply> <minus/> <infinity/> </apply>\n"
     );
       N = new ASTNode();
       N.setValue(- util_PosInf());
       S = libsbml.writeMathMLToString(N);
       assertEquals( true, equals(expected,S) );
 }
Esempio n. 9
0
 public void test_MathMLFormatter_cn_rational()
 {
     string expected = wrapMathML("  <cn type=\"rational\"> 1 <sep/> 3 </cn>\n"
     );
       N = new ASTNode();
       N.setValue(((int) 1),3);
       S = libsbml.writeMathMLToString(N);
       assertEquals( true, equals(expected,S) );
 }