changeset 68:ba55a434c9c0

More return test cases.
author volker
date Tue, 22 Mar 2011 23:27:44 +0100
parents d1f8574aede4
children 87dfb067ca0e
files src/test/java/org/icedrobot/daneel/junit/TestUtils.java src/test/java/org/icedrobot/daneel/rewriter/DexRewriter_MethodRewriterTest.java src/test/java/resources/classes.dex
diffstat 3 files changed, 46 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/test/java/org/icedrobot/daneel/junit/TestUtils.java	Sat Mar 19 21:10:34 2011 +0100
+++ b/src/test/java/org/icedrobot/daneel/junit/TestUtils.java	Tue Mar 22 23:27:44 2011 +0100
@@ -48,7 +48,7 @@
 
     /**
      * Create a ClassLoader from the IcedRobot test Android Package file
-     * (*.apk).
+     * (*.apk). The source are currently at http://icedtea.classpath.org/people/volker/IcedRobotAndroidTests/
      * 
      * @return a singleton instance
      */
@@ -59,7 +59,11 @@
             file[0] = new File(
                     "../IcedRobotAndroidTests/bin/IcedRobotAndroidTests.apk");
             if (!file[0].exists()) {
-                // search on another location
+                file[0] = new File("../IcedRobotAndroidTests/bin/classes.dex");
+            }
+            if (!file[0].exists()) {
+                //temporary until the maven build is finish
+                file[0] = new File("target/test-classes/resources/classes.dex");
             }
             daneelClassLoader = new DaneelClassLoader(
                     ClassLoader.getSystemClassLoader(), file);
--- a/src/test/java/org/icedrobot/daneel/rewriter/DexRewriter_MethodRewriterTest.java	Sat Mar 19 21:10:34 2011 +0100
+++ b/src/test/java/org/icedrobot/daneel/rewriter/DexRewriter_MethodRewriterTest.java	Tue Mar 22 23:27:44 2011 +0100
@@ -39,9 +39,6 @@
 
 import static org.junit.Assert.assertEquals;
 
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
 import org.icedrobot.daneel.junit.TestUtils;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -63,12 +60,52 @@
     }
 
     @Test
+    public void returnLong() throws Exception {
+        assertEquals(-1L, TestUtils.invokeDexTestMethod(instance));
+    }
+
+    @Test
     public void returnInt() throws Exception {
         assertEquals(25, TestUtils.invokeDexTestMethod(instance));
     }
 
     @Test
+    public void returnShort() throws Exception {
+        assertEquals((short)-1, TestUtils.invokeDexTestMethod(instance));
+    }
+
+    @Test
+    public void returnByte() throws Exception {
+        assertEquals((byte)-25, TestUtils.invokeDexTestMethod(instance));
+    }
+
+    @Test
+    public void returnChar() throws Exception {
+        assertEquals('a', TestUtils.invokeDexTestMethod(instance));
+    }
+
+    @Test
+    public void returnDouble() throws Exception {
+        assertEquals(Double.valueOf(44), TestUtils.invokeDexTestMethod(instance));
+    }
+
+    @Test
     public void returnFloat() throws Exception {
         assertEquals(Float.valueOf(37), TestUtils.invokeDexTestMethod(instance));
     }
+
+    @Test
+    public void returnThis() throws Exception {
+        assertEquals(instance, TestUtils.invokeDexTestMethod(instance));
+    }
+
+    //@Test
+    public void returnNull() throws Exception {
+        assertEquals(null, TestUtils.invokeDexTestMethod(instance));
+    }
+
+    @Test
+    public void returnString() throws Exception {
+        assertEquals("any string", TestUtils.invokeDexTestMethod(instance));
+    }
 }
Binary file src/test/java/resources/classes.dex has changed