44 lines
1.2 KiB
Java
44 lines
1.2 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 WhileTest {
|
|
private static Class<?> classToTest;
|
|
private static Object instanceOfClass;
|
|
|
|
@BeforeClass
|
|
public static void setUpBeforeClass() throws Exception {
|
|
var classFiles = TestCodegen.generateClassFiles(new ByteArrayClassLoader(), "While.jav");
|
|
classToTest = classFiles.get("While");
|
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void test() throws Exception {
|
|
Method m = classToTest.getDeclaredMethod("m", Integer.class);
|
|
Integer result = (Integer) m.invoke(instanceOfClass, 0);
|
|
assertEquals(Integer.valueOf(2), result);
|
|
}
|
|
|
|
@Test
|
|
public void testDouble() throws Exception {
|
|
Method m = classToTest.getDeclaredMethod("m", Double.class);
|
|
Double result = (Double) m.invoke(instanceOfClass, 0.0);
|
|
assertEquals(Double.valueOf(2.0), result);
|
|
}
|
|
|
|
@Test
|
|
public void testLong() throws Exception {
|
|
Method m = classToTest.getDeclaredMethod("m", Long.class);
|
|
Long result = (Long) m.invoke(instanceOfClass, 0l);
|
|
assertEquals(Long.valueOf(2l), result);
|
|
}
|
|
|
|
}
|