JavaPatternMatching/test/bytecode/operators/AddDoubleOperatorTest.java

54 lines
1.2 KiB
Java
Raw Normal View History

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);
}
}