JavaTXCompilerInJavaTXNoMaven/tests/targetast/PostIncTest.java
2024-05-02 23:04:07 +02:00

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 PostIncTest {
private static Class<?> classToTest;
private static Object instanceOfClass;
@BeforeClass
public static void setUpBeforeClass() throws Exception {
var classFiles = TestCodegen.generateClassFiles(new ByteArrayClassLoader(), "PostIncDec.jav");
classToTest = classFiles.get("PostIncDec");
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
}
@Test
public void testM1() 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(0), res);
}
@Test
public void testD1() 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(0), res);
}
}