JavaCompilerCore/test/bytecode/operators/AddDoubleOperatorTest.java
Enrico Schrödter 32741f41e9 - Addition für alle Typen implementiert
- Mehrere Klassen in einer jav Datei möglich
- OLTest läuft
2016-04-29 15:52:20 +02:00

54 lines
1.2 KiB
Java

package bytecode.operators;
import static org.junit.Assert.*;
import java.io.File;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Vector;
import org.junit.Ignore;
import org.junit.Test;
import bytecode.SourceFileBytecodeTest;
public class AddDoubleOperatorTest extends SourceFileBytecodeTest{
@Override
protected void init() {
testName = "AddDoubleOperator";
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/operators/";
}
@Test
public void testConstruct() throws Exception{
ClassLoader classLoader = getClassLoader();
Class cls = classLoader.loadClass(testName);
Object obj = cls.newInstance();
assertTrue(true);
}
@Test
public void testTwoDoubles() throws Exception{
ClassLoader classLoader = getClassLoader();
Class cls = classLoader.loadClass(testName);
Object obj = cls.newInstance();
Double x = new Double(1);
Double y = new Double(2);
Class[] params = new Class[]{
x.getClass(),
y.getClass(),
};
Method method = cls.getDeclaredMethod("method", params);
Double returnValue = (Double) method.invoke(obj, x, y);
assertEquals(new Double(3.0), returnValue);
}
}