use of org.evosuite.symbolic.expr.Constraint in project evosuite by EvoSuite.
the class TestRealSearch method testLTConstantAfterComma.
@Test
public void testLTConstantAfterComma() {
List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
constraints.add(new RealConstraint(new RealVariable("test1", 2.35086, -1000000.0, 1000000.0), Comparator.LT, 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.Constraint 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.Constraint 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.Constraint in project evosuite by EvoSuite.
the class TestStringSearch2 method testSolveIndexOfConstant.
@Test
public void testSolveIndexOfConstant() throws SecurityException, NoSuchMethodException {
DefaultTestCase tc = buildTestCase("V*X-:o%tp");
List<BranchCondition> branch_conditions = executeTest(tc);
Collection<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
for (int i = 0; i < branch_conditions.size() - 2; i++) {
BranchCondition b = branch_conditions.get(i);
constraints.addAll(b.getSupportingConstraints());
constraints.add(b.getConstraint());
}
BranchCondition last_branch = branch_conditions.get(branch_conditions.size() - 2);
constraints.addAll(last_branch.getSupportingConstraints());
constraints.add(last_branch.getConstraint().negate());
EvoSuiteSolver solver = new EvoSuiteSolver();
Map<String, Object> solution;
try {
solution = solve(solver, constraints);
assertNotNull(solution);
System.out.println(solution);
} catch (SolverTimeoutException e) {
fail();
}
}
use of org.evosuite.symbolic.expr.Constraint in project evosuite by EvoSuite.
the class TestStringSearch2 method testSolvePathConstraint.
@Test
public void testSolvePathConstraint() throws SecurityException, NoSuchMethodException {
DefaultTestCase tc = buildTestCase("urn:pBth:/A/B/C/doc.html#gilada");
List<BranchCondition> branch_conditions = executeTest(tc);
Collection<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
for (int i = 0; i < branch_conditions.size() - 1; i++) {
BranchCondition b = branch_conditions.get(i);
constraints.addAll(b.getSupportingConstraints());
constraints.add(b.getConstraint());
}
BranchCondition last_branch = branch_conditions.get(branch_conditions.size() - 1);
constraints.addAll(last_branch.getSupportingConstraints());
constraints.add(last_branch.getConstraint().negate());
EvoSuiteSolver solver = new EvoSuiteSolver();
Map<String, Object> solution;
try {
solution = solve(solver, constraints);
assertNotNull(solution);
System.out.println(solution);
} catch (SolverTimeoutException e) {
fail();
}
}
Aggregations