use of org.evosuite.symbolic.expr.bv.IntegerVariable in project evosuite by EvoSuite.
the class SymbolicObserver method after.
private void after(BooleanPrimitiveStatement statement, Scope scope) {
boolean valueOf = statement.getValue();
VariableReference varRef = statement.getReturnValue();
String varRefName = varRef.getName();
IntegerVariable integerVariable = buildIntegerVariable(varRefName, valueOf ? 1 : 0, 0, 1);
Boolean boolean_instance;
try {
boolean_instance = (Boolean) varRef.getObject(scope);
} catch (CodeUnderTestException e) {
throw new EvosuiteError(e);
}
symb_expressions.put(varRefName, integerVariable);
ReferenceConstant booleanRef = newBooleanReference(boolean_instance, integerVariable);
symb_references.put(varRefName, booleanRef);
}
use of org.evosuite.symbolic.expr.bv.IntegerVariable in project evosuite by EvoSuite.
the class SymbolicObserver method buildIntegerVariable.
private IntegerVariable buildIntegerVariable(String name, long conV, long minValue, long maxValue) {
IntegerVariable integerVariable;
if (integerVariables.containsKey(name)) {
integerVariable = integerVariables.get(name);
integerVariable.setConcreteValue(conV);
assert minValue == integerVariable.getMinValue();
assert maxValue == integerVariable.getMaxValue();
} else {
integerVariable = new IntegerVariable(name, conV, minValue, maxValue);
integerVariables.put(name, integerVariable);
}
return integerVariable;
}
use of org.evosuite.symbolic.expr.bv.IntegerVariable in project evosuite by EvoSuite.
the class SymbolicObserver method after.
private void after(ShortPrimitiveStatement statement, Scope scope) {
short valueOf = statement.getValue();
VariableReference varRef = statement.getReturnValue();
String varRefName = varRef.getName();
IntegerVariable integerVariable = buildIntegerVariable(varRefName, valueOf, Short.MIN_VALUE, Short.MAX_VALUE);
symb_expressions.put(varRefName, integerVariable);
Short short_instance;
try {
short_instance = (Short) varRef.getObject(scope);
} catch (CodeUnderTestException e) {
throw new EvosuiteError(e);
}
ReferenceConstant shortRef = newShortReference(short_instance, integerVariable);
symb_references.put(varRefName, shortRef);
}
use of org.evosuite.symbolic.expr.bv.IntegerVariable in project evosuite by EvoSuite.
the class SymbolicObserver method after.
private void after(IntPrimitiveStatement statement, Scope scope) {
int valueOf = statement.getValue();
VariableReference varRef = statement.getReturnValue();
String varRefName = varRef.getName();
IntegerVariable integerVariable = buildIntegerVariable(varRefName, valueOf, Integer.MIN_VALUE, Integer.MAX_VALUE);
symb_expressions.put(varRefName, integerVariable);
Integer integer_instance;
try {
integer_instance = (Integer) varRef.getObject(scope);
} catch (CodeUnderTestException e) {
throw new EvosuiteError(e);
}
ReferenceConstant integerRef = newIntegerReference(integer_instance, integerVariable);
symb_references.put(varRefName, integerRef);
}
use of org.evosuite.symbolic.expr.bv.IntegerVariable in project evosuite by EvoSuite.
the class TestIntegerSearch method testEQVariable.
@Test
public void testEQVariable() throws SolverEmptyQueryException {
int var1 = 0;
int var2 = 1;
List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
constraints.add(new IntegerConstraint(new IntegerVariable("test1", var1, -1000000, 1000000), Comparator.EQ, new IntegerVariable("test2", var2, -1000000, 1000000)));
try {
EvoSuiteSolver solver = new EvoSuiteSolver();
SolverResult solverResult = solver.solve(constraints);
assertTrue(solverResult.isSAT());
Map<String, Object> model = solverResult.getModel();
if (model.containsKey("test1"))
var1 = ((Number) model.get("test1")).intValue();
if (model.containsKey("test2"))
var2 = ((Number) model.get("test2")).intValue();
assertEquals(var1, var2);
} catch (SolverTimeoutException e) {
fail();
}
}
Aggregations