121 lines
4.3 KiB
Java
121 lines
4.3 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.assertFalse;
|
|
import static org.junit.Assert.assertTrue;
|
|
|
|
public class LessThanTest {
|
|
static Class<?> classToTest;
|
|
static Object instance;
|
|
|
|
@BeforeClass
|
|
public static void beforeClass() throws Exception {
|
|
var classFiles = TestCodegen.generateClassFiles(new ByteArrayClassLoader(), "LessThan.jav");
|
|
classToTest = classFiles.get("LessThan");
|
|
instance = classToTest.getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void testLessThanInt() throws Exception {
|
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Integer.class,Integer.class);
|
|
Boolean result = (Boolean) lessThan.invoke(instance, 5, 7);
|
|
assertTrue(result);
|
|
}
|
|
|
|
@Test
|
|
public void testLessThanInt2() throws Exception {
|
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Integer.class, Integer.class);
|
|
Boolean result = (Boolean) lessThan.invoke(instance, 7, 5);
|
|
assertFalse(result);
|
|
}
|
|
|
|
@Test
|
|
public void testLessThanInt3() throws Exception {
|
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Integer.class, Integer.class);
|
|
Boolean result = (Boolean) lessThan.invoke(instance, 5, 5);
|
|
assertFalse(result);
|
|
}
|
|
|
|
@Test
|
|
public void testLessThanLong() throws Exception {
|
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Long.class,Long.class);
|
|
Boolean result = (Boolean) lessThan.invoke(instance, 5L, 7L);
|
|
assertTrue(result);
|
|
}
|
|
|
|
@Test
|
|
public void testLessThanLong2() throws Exception {
|
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Long.class, Long.class);
|
|
Boolean result = (Boolean) lessThan.invoke(instance, 7L, 5L);
|
|
assertFalse(result);
|
|
}
|
|
|
|
@Test
|
|
public void testLessThanLong3() throws Exception {
|
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Long.class, Long.class);
|
|
Boolean result = (Boolean) lessThan.invoke(instance, 5L, 5L);
|
|
assertFalse(result);
|
|
}
|
|
|
|
@Test
|
|
public void testLessThanFloat() throws Exception {
|
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Float.class, Float.class);
|
|
Boolean result = (Boolean) lessThan.invoke(instance, 7F, 5F);
|
|
assertFalse(result);
|
|
}
|
|
|
|
@Test
|
|
public void testLessThanDouble() throws Exception {
|
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Double.class, Double.class);
|
|
Boolean result = (Boolean) lessThan.invoke(instance, 7.0, 5.0);
|
|
assertFalse(result);
|
|
}
|
|
|
|
@Test
|
|
public void testLessThanLongInt() throws Exception {
|
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Long.class, Integer.class);
|
|
Boolean result = (Boolean) lessThan.invoke(instance, 7L, 5);
|
|
assertFalse(result);
|
|
}
|
|
|
|
@Test
|
|
public void testLessThanFloatInt() throws Exception {
|
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Float.class, Integer.class);
|
|
Boolean result = (Boolean) lessThan.invoke(instance, 7F, 5);
|
|
assertFalse(result);
|
|
}
|
|
|
|
@Test
|
|
public void testLessThanDoubleInt() throws Exception {
|
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Double.class, Integer.class);
|
|
Boolean result = (Boolean) lessThan.invoke(instance, 7.0, 5);
|
|
assertFalse(result);
|
|
}
|
|
|
|
@Test
|
|
public void testLessThanFloatLong() throws Exception {
|
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Float.class, Long.class);
|
|
Boolean result = (Boolean) lessThan.invoke(instance, 7F, 5L);
|
|
assertFalse(result);
|
|
}
|
|
|
|
@Test
|
|
public void testLessThanDoubleLong() throws Exception {
|
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Double.class, Long.class);
|
|
Boolean result = (Boolean) lessThan.invoke(instance, 7.0, 5L);
|
|
assertFalse(result);
|
|
}
|
|
|
|
@Test
|
|
public void testLessThanDoubleFloat() throws Exception {
|
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Double.class, Float.class);
|
|
Boolean result = (Boolean) lessThan.invoke(instance, 7.0, 5F);
|
|
assertFalse(result);
|
|
}
|
|
}
|