1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.asn1.ber.digester;
18
19
20 import junit.framework.*;
21 import org.apache.asn1.ber.digester.TagNode;
22
23
24 /***
25 * Unit test for the TagNode class.
26 *
27 * @author <a href="mailto:dev@directory.apache.org">
28 * Apache Directory Project</a>
29 * @version $Rev: 157644 $
30 */
31 public class TagNodeTest extends TestCase
32 {
33 TagNode n0 = null ;
34 TagNode n1 = null ;
35 TagNode n2 = null ;
36
37
38 public void setUp() throws Exception
39 {
40 super.setUp() ;
41
42 n0 = new TagNode( new Integer( 0 ) ) ;
43 n1 = new TagNode( new Integer( 1 ) ) ;
44 n2 = new TagNode( new Integer( 2 ) ) ;
45 }
46
47 /***
48 * Tests the TagNode.getDepth() method.
49 */
50 public void testDepth()
51 {
52 assertEquals( 0, n0.getDepth() ) ;
53 n0.addNode( n1 ) ;
54 assertEquals( 0, n0.getDepth() ) ;
55 assertEquals( 1, n1.getDepth() ) ;
56 n1.addNode( n2 ) ;
57 assertEquals( 0, n0.getDepth() ) ;
58 assertEquals( 1, n1.getDepth() ) ;
59 assertEquals( 2, n2.getDepth() ) ;
60 }
61
62
63 /***
64 * Tests the TagNode.hasChildren() method.
65 */
66 public void testHasChildren()
67 {
68 assertFalse( n0.hasChild( new Integer( 1 ) ) ) ;
69 n0.addNode( n1 ) ;
70 assertTrue( n0.hasChild( new Integer( 1 ) ) ) ;
71 }
72 }