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

113 lines
4.0 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 LessEqualTest {
static Class<?> classToTest;
static Object instance;
@BeforeClass
public static void beforeClass() throws Exception {
var classFiles = TestCodegen.generateClassFiles(new ByteArrayClassLoader(), "LessEqual.jav");
classToTest = classFiles.get("LessEqual");
instance = classToTest.getDeclaredConstructor().newInstance();
}
@Test
public void testIntegers() throws Exception {
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Integer.class, Integer.class);
Boolean result = (Boolean) lessEqual.invoke(instance, 5,7);
assertTrue(result);
}
@Test
public void testEqualIntegers() throws Exception {
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Integer.class, Integer.class);
Boolean result = (Boolean) lessEqual.invoke(instance, 5,5);
assertTrue(result);
}
@Test
public void testLongs() throws Exception {
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Long.class, Long.class);
Boolean result = (Boolean) lessEqual.invoke(instance, 5L,7L);
assertTrue(result);
}@Test
public void testFloats() throws Exception {
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Float.class, Float.class);
Boolean result = (Boolean) lessEqual.invoke(instance, 5F,7F);
assertTrue(result);
}
@Test
public void testDoubles() throws Exception {
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Double.class, Double.class);
Boolean result = (Boolean) lessEqual.invoke(instance, 5.0,7.0);
assertTrue(result);
}
@Test
public void testLongInt() throws Exception {
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Long.class, Integer.class);
Boolean result = (Boolean) lessEqual.invoke(instance, 5L,7);
assertTrue(result);
}
@Test
public void testFloatInt() throws Exception {
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Float.class, Integer.class);
Boolean result = (Boolean) lessEqual.invoke(instance, 5F,7);
assertTrue(result);
}
@Test
public void testDoubleInt() throws Exception {
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Double.class, Integer.class);
Boolean result = (Boolean) lessEqual.invoke(instance, 5.0,7);
assertTrue(result);
}
@Test
public void testFloatLong() throws Exception {
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Float.class, Long.class);
Boolean result = (Boolean) lessEqual.invoke(instance, 5F,7L);
assertTrue(result);
}
@Test
public void testDoubleLong() throws Exception {
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Double.class, Long.class);
Boolean result = (Boolean) lessEqual.invoke(instance, 5.0,7L);
assertTrue(result);
}
@Test
public void testEqDoubleFloat() throws Exception {
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Double.class, Float.class);
Boolean result = (Boolean) lessEqual.invoke(instance, 7.0,7F);
assertTrue(result);
}
@Test
public void testDoubleFloat() throws Exception {
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Double.class, Float.class);
Boolean result = (Boolean) lessEqual.invoke(instance, 5.0,7F);
assertTrue(result);
}
@Test
public void testDoubleFloat3() throws Exception {
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Double.class, Float.class);
Boolean result = (Boolean) lessEqual.invoke(instance, 9.0,7F);
assertFalse(result);
}
}