You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-dev@jakarta.apache.org by db...@apache.org on 2007/06/23 19:47:39 UTC
svn commit: r550066 -
/jakarta/bcel/trunk/src/test/java/org/apache/bcel/InstructionFinderTestCase.java
Author: dbrosius
Date: Sat Jun 23 10:47:38 2007
New Revision: 550066
URL: http://svn.apache.org/viewvc?view=rev&rev=550066
Log:
Add test case to show that InstructionFinder.search returns one more value than supposed to, issue found by Nicholson, Jonathan O H
Added:
jakarta/bcel/trunk/src/test/java/org/apache/bcel/InstructionFinderTestCase.java
Added: jakarta/bcel/trunk/src/test/java/org/apache/bcel/InstructionFinderTestCase.java
URL: http://svn.apache.org/viewvc/jakarta/bcel/trunk/src/test/java/org/apache/bcel/InstructionFinderTestCase.java?view=auto&rev=550066
==============================================================================
--- jakarta/bcel/trunk/src/test/java/org/apache/bcel/InstructionFinderTestCase.java (added)
+++ jakarta/bcel/trunk/src/test/java/org/apache/bcel/InstructionFinderTestCase.java Sat Jun 23 10:47:38 2007
@@ -0,0 +1,45 @@
+package org.apache.bcel;
+
+import java.util.Iterator;
+
+import org.apache.bcel.AbstractTestCase;
+import org.apache.bcel.classfile.JavaClass;
+import org.apache.bcel.classfile.Method;
+import org.apache.bcel.generic.InstructionList;
+import org.apache.bcel.util.InstructionFinder;
+import org.apache.bcel.util.InstructionFinder.CodeConstraint;
+
+public class InstructionFinderTestCase extends AbstractTestCase
+{
+ public void testSearchAll() throws Exception
+ {
+ JavaClass clazz = getTestClass("org.apache.bcel.util.InstructionFinder");
+ Method[] methods = clazz.getMethods();
+ Method searchM = null;
+ for (Method m : methods)
+ {
+ if (m.getName().equals("search") && (m.getArgumentTypes().length == 3))
+ {
+ searchM = m;
+ break;
+ }
+ }
+
+ if (searchM == null)
+ throw new Exception("search method not found");
+
+ byte[] bytes = searchM.getCode().getCode();
+ InstructionList il = new InstructionList(bytes);
+ InstructionFinder finder = new InstructionFinder(il);
+ Iterator it = finder.search(".*", il.getStart(), null);
+
+ int cnt = 0;
+ while (it.hasNext())
+ {
+ it.next();
+ cnt++;
+ }
+
+ assertEquals(1, cnt);
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-dev-help@jakarta.apache.org