01: /*
02: * Created on Nov 28, 2003
03: *
04: * To change the template for this generated file go to
05: * Window>Preferences>Java>Code Generation>Code and Comments
06: */
07: package org.hammurapi.inspectors.metrics.callertrace.tests;
08:
09: import java.util.SortedMap;
10: import java.util.TreeMap;
11:
12: import junit.framework.Test;
13: import junit.framework.TestCase;
14: import junit.framework.TestSuite;
15:
16: import org.hammurapi.inspectors.metrics.callertrace.MethodWrapper;
17: import org.hammurapi.inspectors.metrics.callertrace.MethodWrapperDeclaration;
18: import org.hammurapi.inspectors.metrics.callertrace.TracedMethodLocComparator;
19:
20: /**
21: * @author mucbj0
22: *
23: * To change the template for this generated type comment go to
24: * Window>Preferences>Java>Code Generation>Code and Comments
25: */
26: public class TracedMethodLocComparatorTest extends TestCase {
27:
28: public static Test suite() {
29: return new TestSuite(TracedMethodLocComparatorTest.class);
30: }
31:
32: public void testSorted1() {
33:
34: SortedMap keyMethodList = new TreeMap(
35: new TracedMethodLocComparator());
36: MethodWrapper m = new MethodWrapperDeclaration("", "MyClass");
37: m.setLine(1);
38: keyMethodList.put(m, m);
39: m = new MethodWrapperDeclaration("", "MyClass");
40: m.setLine(20);
41: keyMethodList.put(m, m);
42: m = new MethodWrapperDeclaration("", "MyClass");
43: m.setLine(30);
44: keyMethodList.put(m, m);
45: m = (MethodWrapperDeclaration) keyMethodList.firstKey();
46:
47: assertTrue("keyMethodList.size() should be 3 but is "
48: + keyMethodList.size(), keyMethodList.size() == 3);
49:
50: m = (MethodWrapperDeclaration) keyMethodList.lastKey();
51: assertTrue("m.getLine() should be 30 but is " + m.getLine(), m
52: .getLine() == 30);
53:
54: }
55: }
|