use of org.evosuite.symbolic.expr.fp.RealConstant in project evosuite by EvoSuite.
the class TestRealSearch method testGTConstant.
@Test
public void testGTConstant() {
List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
constraints.add(new RealConstraint(new RealVariable("test1", 0, -1000000.0, 1000000.0), Comparator.GT, new RealConstant(2.35082)));
EvoSuiteSolver skr = new EvoSuiteSolver();
Map<String, Object> result;
try {
result = solve(skr, constraints);
assertNotNull(result);
assertNotNull(result.get("test1"));
assertTrue(2.35082 < ((Number) result.get("test1")).doubleValue());
} catch (SolverTimeoutException e) {
fail();
}
}
use of org.evosuite.symbolic.expr.fp.RealConstant in project evosuite by EvoSuite.
the class TestRealSearch method testEvosuiteExample2.
@Test
public void testEvosuiteExample2() {
double var1 = 355.80758027529504;
// var3__SYM(355.80758027529504) >= 0.0 dist: 177.90379013764752
// var3__SYM(355.80758027529504) == 0.0 dist: 177.90379013764752
RealVariable realVar = new RealVariable("test1", var1, -1000000, 1000000);
List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
constraints.add(new RealConstraint(realVar, Comparator.GE, new RealConstant(0.0)));
constraints.add(new RealConstraint(realVar, Comparator.EQ, new RealConstant(0.0)));
EvoSuiteSolver skr = new EvoSuiteSolver();
Map<String, Object> result;
try {
result = solve(skr, constraints);
assertNotNull(result);
if (result.containsKey("test1"))
var1 = ((Number) result.get("test1")).doubleValue();
assertEquals(0, var1, 0.0001);
} catch (SolverTimeoutException e) {
fail();
}
}
use of org.evosuite.symbolic.expr.fp.RealConstant in project evosuite by EvoSuite.
the class TestRealConstraint method buildConstraintSystem.
private static Collection<Constraint<?>> buildConstraintSystem() {
RealVariable var0 = new RealVariable("var0", INIT_DOUBLE, Double.MIN_VALUE, Double.MAX_VALUE);
RealConstant constPi = new RealConstant(Math.PI);
RealConstraint constr1 = new RealConstraint(var0, Comparator.EQ, constPi);
return Arrays.<Constraint<?>>asList(constr1);
}
use of org.evosuite.symbolic.expr.fp.RealConstant in project evosuite by EvoSuite.
the class CallVM method CALL_RESULT.
@Override
public void CALL_RESULT(double res, String owner, String name, String desc) {
CALL_RESULT(owner, name, desc);
if (env.topFrame().weInvokedInstrumentedCode()) {
// RETURN already did it
return;
} else {
/**
* We are returning from uninstrumented code. This is the only way
* of storing the uninstrumented return value to the symbolic state.
*/
RealConstant value = ExpressionFactory.buildNewRealConstant(res);
env.topFrame().operandStack.pushFp64(value);
}
}
use of org.evosuite.symbolic.expr.fp.RealConstant in project evosuite by EvoSuite.
the class CallVM method CALL_RESULT.
@Override
public void CALL_RESULT(float res, String owner, String name, String desc) {
CALL_RESULT(owner, name, desc);
if (env.topFrame().weInvokedInstrumentedCode()) {
// it
return;
} else {
/**
* We are returning from uninstrumented code. This is the only way
* of storing the uninstrumented return value to the symbolic state.
*/
RealConstant value = ExpressionFactory.buildNewRealConstant(res);
env.topFrame().operandStack.pushFp32(value);
}
}
Aggregations