use of org.evosuite.testcase.statements.EnumPrimitiveStatement in project evosuite by EvoSuite.
the class EnumLocalSearch method doSearch.
/* (non-Javadoc)
* @see org.evosuite.testcase.LocalSearch#doSearch(org.evosuite.testcase.TestChromosome, int, org.evosuite.ga.LocalSearchObjective)
*/
/**
* {@inheritDoc}
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public boolean doSearch(TestChromosome test, int statement, LocalSearchObjective<TestChromosome> objective) {
EnumPrimitiveStatement p = (EnumPrimitiveStatement) test.getTestCase().getStatement(statement);
ExecutionResult oldResult = test.getLastExecutionResult();
oldValue = p.getValue();
for (Object value : p.getEnumValues()) {
p.setValue(value);
if (!objective.hasImproved(test)) {
// Restore original
p.setValue(oldValue);
test.setLastExecutionResult(oldResult);
test.setChanged(false);
} else {
logger.debug("Finished local search with result " + p.getCode());
return true;
}
}
return false;
}
use of org.evosuite.testcase.statements.EnumPrimitiveStatement in project evosuite by EvoSuite.
the class TestCaseBuilder method appendEnumPrimitive.
public VariableReference appendEnumPrimitive(Enum<?> value) {
EnumPrimitiveStatement primitiveStmt = new EnumPrimitiveStatement(tc, value);
tc.addStatement(primitiveStmt);
return primitiveStmt.getReturnValue();
}
Aggregations