ASTUtilTestpublic class ASTUtilTest extends org.hibernate.junit.UnitTestCase
Fields Summary |
---|
private antlr.ASTFactory | factory |
Constructors Summary |
---|
public ASTUtilTest(String name)Standard JUnit test case constructor.
super( name );
|
Methods Summary |
---|
protected void | setUp()
super.setUp();
factory = new ASTFactory();
| public static junit.framework.Test | suite()
return new TestSuite( ASTUtilTest.class );
| public void | testCreate()
AST n = ASTUtil.create( factory, 1, "one");
assertNull( n.getFirstChild() );
assertEquals("one",n.getText());
assertEquals(1,n.getType());
| public void | testCreateTree()Test adding a tree of children.
AST[] tree = new AST[4];
AST grandparent = tree[0] = ASTUtil.create(factory, 1, "grandparent");
AST parent = tree[1] = ASTUtil.create(factory,2,"parent");
AST child = tree[2] = ASTUtil.create(factory,3,"child");
AST baby = tree[3] = ASTUtil.create(factory,4,"baby");
AST t = ASTUtil.createTree( factory, tree);
assertSame(t,grandparent);
assertSame(parent,t.getFirstChild());
assertSame(child,t.getFirstChild().getFirstChild());
assertSame(baby,t.getFirstChild().getFirstChild().getFirstChild());
| public void | testFindPreviousSibling()
AST child1 = ASTUtil.create(factory,2, "child1");
AST child2 = ASTUtil.create(factory,3, "child2");
AST n = factory.make( new AST[] {
ASTUtil.create(factory, 1, "parent"),
child1,
child2,
});
assertSame(child1,ASTUtil.findPreviousSibling( n,child2));
Exception e = null;
try {
ASTUtil.findPreviousSibling(child1,null);
}
catch (Exception x) {
e = x;
}
assertNotNull(e);
|
|