Search in sources :

Example 1 with ClassPrimitiveStatement

use of org.evosuite.testcase.statements.ClassPrimitiveStatement in project evosuite by EvoSuite.

the class TestCaseBuilder method appendClassPrimitive.

public VariableReference appendClassPrimitive(Class<?> value) {
    ClassPrimitiveStatement stmt = new ClassPrimitiveStatement(tc, value);
    tc.addStatement(stmt);
    return stmt.getReturnValue();
}
Also used : ClassPrimitiveStatement(org.evosuite.testcase.statements.ClassPrimitiveStatement)

Example 2 with ClassPrimitiveStatement

use of org.evosuite.testcase.statements.ClassPrimitiveStatement in project evosuite by EvoSuite.

the class EvoTestCaseCodeGenerator method createPlainInitStmt.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void createPlainInitStmt(CaptureLog log, int logRecNo) {
    // NOTE: PLAIN INIT: has always one non-null param
    // TODO: use primitives
    final int oid = log.objectIds.get(logRecNo);
    if (this.oidToVarRefMap.containsKey(oid)) {
        // TODO this might happen because of Integer.valueOf(), for example. . Is this approach ok?
        return;
    }
    final String type = log.getTypeName(oid);
    final Object value = log.params.get(logRecNo)[0];
    final VariableReference varRef;
    if (value instanceof Class) {
        // final PrimitiveStatement cps = ClassPrimitiveStatement.getPrimitiveStatement(testCase, getClassForName(type));
        final PrimitiveStatement cps = new ClassPrimitiveStatement(testCase, getClassForName(type));
        cps.setValue(value);
        varRef = testCase.addStatement(cps);
    } else {
        final PrimitiveStatement primitiveValue = PrimitiveStatement.getPrimitiveStatement(testCase, getClassForName(type));
        primitiveValue.setValue(value);
        varRef = testCase.addStatement(primitiveValue);
    }
    this.oidToVarRefMap.put(oid, varRef);
}
Also used : VariableReference(org.evosuite.testcase.variable.VariableReference) ClassPrimitiveStatement(org.evosuite.testcase.statements.ClassPrimitiveStatement) PrimitiveStatement(org.evosuite.testcase.statements.PrimitiveStatement) ImmutableStringPrimitiveStatement(org.evosuite.testcase.statements.ImmutableStringPrimitiveStatement) ClassPrimitiveStatement(org.evosuite.testcase.statements.ClassPrimitiveStatement)

Aggregations

ClassPrimitiveStatement (org.evosuite.testcase.statements.ClassPrimitiveStatement)2 ImmutableStringPrimitiveStatement (org.evosuite.testcase.statements.ImmutableStringPrimitiveStatement)1 PrimitiveStatement (org.evosuite.testcase.statements.PrimitiveStatement)1 VariableReference (org.evosuite.testcase.variable.VariableReference)1