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

134 lines
4.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.assertFalse;
import static org.junit.Assert.assertTrue;
public class GreaterThanTest {
static Class<?> classToTest;
static Object instance;
@BeforeClass
public static void beforeClass() throws Exception {
var classFiles = TestCodegen.generateClassFiles(new ByteArrayClassLoader(), "GreaterThan.jav");
classToTest = classFiles.get("GreaterThan");
instance = classToTest.getDeclaredConstructor().newInstance();
}
@Test
public void testIntegers() throws Exception {
Method gT = classToTest.getDeclaredMethod("gT", Integer.class, Integer.class);
gT.setAccessible(true);
Boolean result = (Boolean) gT.invoke(instance, 7, 5);
assertTrue(result);
}
@Test
public void testIntegers2() throws Exception {
Method gT = classToTest.getDeclaredMethod("gT", Integer.class, Integer.class);
gT.setAccessible(true);
Boolean result = (Boolean) gT.invoke(instance, 5, 7);
assertFalse(result);
}
@Test
public void testEqIntegers() throws Exception {
Method gT = classToTest.getDeclaredMethod("gT", Integer.class, Integer.class);
gT.setAccessible(true);
Boolean result = (Boolean) gT.invoke(instance, 5, 5);
assertFalse(result);
}
@Test
public void testLongs() throws Exception {
Method gT = classToTest.getDeclaredMethod("gT", Long.class, Long.class);
gT.setAccessible(true);
Boolean result = (Boolean) gT.invoke(instance, 10L,7L);
assertTrue(result);
}@Test
public void testFloats() throws Exception {
Method gT = classToTest.getDeclaredMethod("gT", Float.class, Float.class);
gT.setAccessible(true);
Boolean result = (Boolean) gT.invoke(instance, 5F,7F);
assertFalse(result);
}
@Test
public void testDoubles() throws Exception {
Method gT = classToTest.getDeclaredMethod("gT", Double.class, Double.class);
gT.setAccessible(true);
Boolean result = (Boolean) gT.invoke(instance, 5.0,7.0);
assertFalse(result);
}
@Test
public void testLongInt() throws Exception {
Method gT = classToTest.getDeclaredMethod("gT", Long.class, Integer.class);
gT.setAccessible(true);
Boolean result = (Boolean) gT.invoke(instance, 15L,7);
assertTrue(result);
}
@Test
public void testFloatInt() throws Exception {
Method gT = classToTest.getDeclaredMethod("gT", Float.class, Integer.class);
gT.setAccessible(true);
Boolean result = (Boolean) gT.invoke(instance, 5F,7);
assertFalse(result);
}
@Test
public void testDoubleInt() throws Exception {
Method gT = classToTest.getDeclaredMethod("gT", Double.class, Integer.class);
gT.setAccessible(true);
Boolean result = (Boolean) gT.invoke(instance, 25.0,17);
assertTrue(result);
}
@Test
public void testFloatLong() throws Exception {
Method gT = classToTest.getDeclaredMethod("gT", Float.class, Long.class);
gT.setAccessible(true);
Boolean result = (Boolean) gT.invoke(instance, 75F,70L);
assertTrue(result);
}
@Test
public void testDoubleLong() throws Exception {
Method gT = classToTest.getDeclaredMethod("gT", Double.class, Long.class);
gT.setAccessible(true);
Boolean result = (Boolean) gT.invoke(instance, 5.0,7L);
assertFalse(result);
}
@Test
public void testEqDoubleFloat() throws Exception {
Method gT = classToTest.getDeclaredMethod("gT", Double.class, Float.class);
gT.setAccessible(true);
Boolean result = (Boolean) gT.invoke(instance, 7.0,7F);
assertFalse(result);
}
@Test
public void testDoubleFloat() throws Exception {
Method gT = classToTest.getDeclaredMethod("gT", Double.class, Float.class);
gT.setAccessible(true);
Boolean result = (Boolean) gT.invoke(instance, 15.0,7F);
assertTrue(result);
}
@Test
public void testDoubleFloat3() throws Exception {
Method gT = classToTest.getDeclaredMethod("gT", Double.class, Float.class);
gT.setAccessible(true);
Boolean result = (Boolean) gT.invoke(instance, 9.0,17F);
assertFalse(result);
}
}