01: package org.hanseltest;
02:
03: import junit.framework.TestCase;
04:
05: /**
06: * Test cases for testing expressions on the stack.
07: *
08: * @author Niklas Mehner
09: */
10: public class TestBugStackUnderflow extends TestCase {
11: /** Methods of class org.hanseltest.TestBugStackUnderflow. */
12: //private Method[] methods;
13: /** Constant Pool of class org.hanseltest.TestBugStackUnderflow. */
14: // private ConstantPoolGen cpg;
15: /**
16: * Create a new Test.
17: * @param name Name of the test.
18: */
19: /*public TestBugStackUnderflow(String name) {
20: super(name);
21: } */
22:
23: /**
24: * Setup the test.
25: * @throws Exception if loading the example class fails.
26: */
27: /* public void setUp() throws Exception {
28: ClassLoaderRepository repository =
29: new ClassLoaderRepository(getClass().getClassLoader());
30: JavaClass javaClass =
31: repository.loadClass("org.hanseltest.TestBugStackUnderflow");
32: methods = javaClass.getMethods();
33: cpg = new ConstantPoolGen(javaClass.getConstantPool());
34: }
35:
36: /**
37: * Returns the method with the given name.
38: * @param name Name of the method.
39: * @return Method with name 'name'.
40: */
41: /* private MethodGen getMethod(String name) {
42: for (int i = 0; i < methods.length; i++) {
43: if (methods[i].getName().equals(name)) {
44: return new MethodGen(methods[i],
45: "org.hanselexample.stack.StackExample",
46: cpg);
47: }
48: }
49:
50: throw new IllegalStateException("Method not found.");
51: }
52:
53: /**
54: * Tests for a stack underflow.
55: */
56: public void testUnderFlow() {
57: throw new UnsupportedOperationException("Not yet converted");
58: /* // this threw an StackUnderflowException
59: StackFactory sf = new StackFactory(getMethod("getIntArray"));
60: sf.calculateMethodStacks();
61:
62: // Stupid fix for eclipase warning:
63: inBuf = new byte[3];
64: getIntArray();*/
65: }
66:
67: /** The byte array to convert.*/
68: // private byte[] inBuf;
69: /** The int array destination.*/
70: // private int[] outBuf;
71:
72: /**
73: * Converts a byte array to an int array
74: *
75: * @return int[] containing converted byte[]
76: */
77: /* private int[] getIntArray() {
78: // Create the array.
79: outBuf = new int[inBuf.length];
80:
81: int length = outBuf.length;
82: for (int i = 0; i < length; i++) {
83: outBuf[i] = (int) inBuf[i];
84: if (outBuf[i] < 0) {
85: outBuf[i] += 256;
86: }
87: }
88:
89: return (int[]) outBuf.clone();
90: }*/
91: }
|