use of org.evosuite.symbolic.solver.SolverTimeoutException in project evosuite by EvoSuite.
the class TestRealSearch method testLTConstant.
@Test
public void testLTConstant() {
List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
constraints.add(new RealConstraint(new RealVariable("test1", 5.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.solver.SolverTimeoutException in project evosuite by EvoSuite.
the class TestRealSearch method testLEConstantAfterComma.
@Test
public void testLEConstantAfterComma() {
List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
constraints.add(new RealConstraint(new RealVariable("test1", 2.35086, -1000000.0, 1000000.0), Comparator.LE, 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.solver.SolverTimeoutException in project evosuite by EvoSuite.
the class TestRealSearch method testNEConstant.
@Test
public void testNEConstant() {
List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
constraints.add(new RealConstraint(new RealVariable("test1", 2.35082, -1000000.0, 1000000.0), Comparator.NE, 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.solver.SolverTimeoutException in project evosuite by EvoSuite.
the class TestRealSearch method testEQVariable.
@Test
public void testEQVariable() {
double var1 = 0.23123;
double var2 = 1.12321;
List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
constraints.add(new RealConstraint(new RealVariable("test1", var1, -1000000.0, 1000000.0), Comparator.EQ, new RealVariable("test2", var2, -1000000.0, 1000000.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();
if (result.containsKey("test2"))
var2 = ((Number) result.get("test2")).doubleValue();
// assertTrue(var1 == var2);
assertEquals(var1, var2, 0.001);
} catch (SolverTimeoutException e) {
fail();
}
}
use of org.evosuite.symbolic.solver.SolverTimeoutException in project evosuite by EvoSuite.
the class TestRealSearch method testEvosuiteExample1.
@Test
public void testEvosuiteExample1() {
double var1 = 1;
double var2 = 1;
RealVariable realVar1 = new RealVariable("test1", var1, -1000000, 1000000);
RealVariable realVar2 = new RealVariable("test2", var2, -1000000, 1000000);
// x <= 0
// x < y
// x >= 0
List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
constraints.add(new RealConstraint(realVar1, Comparator.LE, new RealConstant(0)));
constraints.add(new RealConstraint(realVar1, Comparator.LT, realVar2));
constraints.add(new RealConstraint(realVar1, Comparator.GE, new RealConstant(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();
if (result.containsKey("test2"))
var2 = ((Number) result.get("test2")).doubleValue();
assertEquals(0, var1, 0.0001);
assertTrue(var1 < var2);
} catch (SolverTimeoutException e) {
fail();
}
}
Aggregations