51 lines
1.4 KiB
Java
51 lines
1.4 KiB
Java
package targetast;
|
|
|
|
import de.dhbwstuttgart.environment.ByteArrayClassLoader;
|
|
import org.junit.BeforeClass;
|
|
import org.junit.Test;
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
public class PreIncTest {
|
|
private static Class<?> classToTest;
|
|
private static Object instanceOfClass;
|
|
|
|
@BeforeClass
|
|
public static void setUpBeforeClass() throws Exception {
|
|
var classFiles = TestCodegen.generateClassFiles(new ByteArrayClassLoader(), "PreInc.jav");
|
|
classToTest = classFiles.get("PreInc");
|
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void testM() throws Exception {
|
|
Method m = classToTest.getDeclaredMethod("m");
|
|
Integer res = (Integer) m.invoke(instanceOfClass);
|
|
assertEquals(Integer.valueOf(1), res);
|
|
}
|
|
|
|
@Test
|
|
public void testM2() throws Exception {
|
|
Method m = classToTest.getDeclaredMethod("m2");
|
|
Integer res = (Integer) m.invoke(instanceOfClass);
|
|
assertEquals(Integer.valueOf(1), res);
|
|
}
|
|
|
|
@Test
|
|
public void testD() throws Exception {
|
|
Method m = classToTest.getDeclaredMethod("d");
|
|
Integer res = (Integer) m.invoke(instanceOfClass);
|
|
assertEquals(Integer.valueOf(-1), res);
|
|
}
|
|
|
|
@Test
|
|
public void testD2() throws Exception {
|
|
Method m = classToTest.getDeclaredMethod("d2");
|
|
Integer res = (Integer) m.invoke(instanceOfClass);
|
|
assertEquals(Integer.valueOf(-1), res);
|
|
}
|
|
|
|
}
|