Search in sources :

Example 1 with FloatPrimitiveStatement

use of org.evosuite.testcase.statements.numeric.FloatPrimitiveStatement in project evosuite by EvoSuite.

the class TestCaseBuilder method appendFloatPrimitive.

public VariableReference appendFloatPrimitive(float f) {
    FloatPrimitiveStatement primitiveStmt = new FloatPrimitiveStatement(tc, f);
    tc.addStatement(primitiveStmt);
    return primitiveStmt.getReturnValue();
}
Also used : FloatPrimitiveStatement(org.evosuite.testcase.statements.numeric.FloatPrimitiveStatement)

Example 2 with FloatPrimitiveStatement

use of org.evosuite.testcase.statements.numeric.FloatPrimitiveStatement in project evosuite by EvoSuite.

the class LocalSearchNumericSystemTest method getFloatTest.

private TestCase getFloatTest(float x, float y) throws NoSuchMethodException, SecurityException, ConstructionFailedException, ClassNotFoundException {
    Class<?> sut = TestGenerationContext.getInstance().getClassLoaderForSUT().loadClass(Properties.TARGET_CLASS);
    GenericClass clazz = new GenericClass(sut);
    DefaultTestCase test = new DefaultTestCase();
    GenericConstructor gc = new GenericConstructor(clazz.getRawClass().getConstructors()[0], clazz);
    TestFactory testFactory = TestFactory.getInstance();
    VariableReference callee = testFactory.addConstructor(test, gc, 0, 0);
    VariableReference intVar1 = test.addStatement(new FloatPrimitiveStatement(test, x));
    VariableReference intVar0 = test.addStatement(new FloatPrimitiveStatement(test, y));
    Method m = clazz.getRawClass().getMethod("testMe", new Class<?>[] { float.class, float.class });
    GenericMethod method = new GenericMethod(m, sut);
    MethodStatement ms = new MethodStatement(test, method, callee, Arrays.asList(new VariableReference[] { intVar0, intVar1 }));
    test.addStatement(ms);
    return test;
}
Also used : MethodStatement(org.evosuite.testcase.statements.MethodStatement) VariableReference(org.evosuite.testcase.variable.VariableReference) FloatPrimitiveStatement(org.evosuite.testcase.statements.numeric.FloatPrimitiveStatement) GenericClass(org.evosuite.utils.generic.GenericClass) TestFactory(org.evosuite.testcase.TestFactory) GenericConstructor(org.evosuite.utils.generic.GenericConstructor) DefaultTestCase(org.evosuite.testcase.DefaultTestCase) GenericMethod(org.evosuite.utils.generic.GenericMethod) Method(java.lang.reflect.Method) GenericMethod(org.evosuite.utils.generic.GenericMethod)

Aggregations

FloatPrimitiveStatement (org.evosuite.testcase.statements.numeric.FloatPrimitiveStatement)2 Method (java.lang.reflect.Method)1 DefaultTestCase (org.evosuite.testcase.DefaultTestCase)1 TestFactory (org.evosuite.testcase.TestFactory)1 MethodStatement (org.evosuite.testcase.statements.MethodStatement)1 VariableReference (org.evosuite.testcase.variable.VariableReference)1 GenericClass (org.evosuite.utils.generic.GenericClass)1 GenericConstructor (org.evosuite.utils.generic.GenericConstructor)1 GenericMethod (org.evosuite.utils.generic.GenericMethod)1