getChild() public method

public getChild ( long n ) : ASTNode
n long
return ASTNode
Example #1
0
 public void test_ASTNode_addChild1()
 {
     ASTNode node = new  ASTNode();
       ASTNode c1 = new  ASTNode();
       ASTNode c2 = new  ASTNode();
       ASTNode c1_1 = new  ASTNode();
       int i = 0;
       node.setType(libsbml.AST_LOGICAL_AND);
       c1.setName( "a");
       c2.setName( "b");
       node.addChild(c1);
       node.addChild(c2);
       assertTrue( node.getNumChildren() == 2 );
       assertTrue((  "and(a, b)" == libsbml.formulaToString(node) ));
       c1_1.setName( "d");
       i = node.addChild(c1_1);
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       assertTrue( node.getNumChildren() == 3 );
       assertTrue((  "and(a, b, d)" == libsbml.formulaToString(node) ));
       assertTrue((  "a" == node.getChild(0).getName() ));
       assertTrue((  "b" == node.getChild(1).getName() ));
       assertTrue((  "d" == node.getChild(2).getName() ));
       node = null;
 }
Example #2
0
 public void test_ASTNode_one_child()
 {
     ASTNode node = new  ASTNode();
       ASTNode child = new  ASTNode();
       node.addChild(child);
       assertTrue( node.getNumChildren() == 1 );
       assertTrue( node.getLeftChild() == child );
       assertTrue( node.getRightChild() == null );
       assertTrue( node.getChild(0) == child );
       assertTrue( node.getChild(1) == null );
       node = null;
 }
Example #3
0
 public void test_ASTNode_no_children()
 {
     ASTNode node = new  ASTNode();
       assertTrue( node.getNumChildren() == 0 );
       assertTrue( node.getLeftChild() == null );
       assertTrue( node.getRightChild() == null );
       assertTrue( node.getChild(0) == null );
       node = null;
 }
Example #4
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;
 }