Search in sources :

Example 46 with EvoSuiteSolver

use of org.evosuite.symbolic.solver.avm.EvoSuiteSolver in project evosuite by EvoSuite.

the class TestRealSearch method testEQConstant.

@Test
public void testEQConstant() {
    List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
    constraints.add(new RealConstraint(new RealVariable("test1", 0.675464, Float.MIN_VALUE, Float.MAX_VALUE), Comparator.EQ, 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();
    }
}
Also used : SolverTimeoutException(org.evosuite.symbolic.solver.SolverTimeoutException) RealConstant(org.evosuite.symbolic.expr.fp.RealConstant) Constraint(org.evosuite.symbolic.expr.Constraint) RealConstraint(org.evosuite.symbolic.expr.RealConstraint) EvoSuiteSolver(org.evosuite.symbolic.solver.avm.EvoSuiteSolver) ArrayList(java.util.ArrayList) RealVariable(org.evosuite.symbolic.expr.fp.RealVariable) RealConstraint(org.evosuite.symbolic.expr.RealConstraint) Test(org.junit.Test)

Example 47 with EvoSuiteSolver

use of org.evosuite.symbolic.solver.avm.EvoSuiteSolver in project evosuite by EvoSuite.

the class TestRealSearch method testAddition.

@Test
public void testAddition() {
    double var1 = 1.0;
    RealVariable realVar1 = new RealVariable("test1", var1, Double.MIN_VALUE, Double.MAX_VALUE);
    List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
    final double doubleValue = 2000.087658834634;
    constraints.add(new RealConstraint(new RealBinaryExpression(new RealConstant(1102.5), Operator.PLUS, realVar1, 1103.5), Comparator.EQ, new RealConstant(doubleValue)));
    assert (DistanceEstimator.getDistance(constraints) > 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(var1, var2, 0.0001);
    } catch (SolverTimeoutException e) {
        fail();
    }
}
Also used : SolverTimeoutException(org.evosuite.symbolic.solver.SolverTimeoutException) Constraint(org.evosuite.symbolic.expr.Constraint) RealConstraint(org.evosuite.symbolic.expr.RealConstraint) EvoSuiteSolver(org.evosuite.symbolic.solver.avm.EvoSuiteSolver) ArrayList(java.util.ArrayList) RealVariable(org.evosuite.symbolic.expr.fp.RealVariable) RealConstant(org.evosuite.symbolic.expr.fp.RealConstant) RealBinaryExpression(org.evosuite.symbolic.expr.fp.RealBinaryExpression) RealConstraint(org.evosuite.symbolic.expr.RealConstraint) Test(org.junit.Test)

Example 48 with EvoSuiteSolver

use of org.evosuite.symbolic.solver.avm.EvoSuiteSolver 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();
    }
}
Also used : SolverTimeoutException(org.evosuite.symbolic.solver.SolverTimeoutException) RealConstant(org.evosuite.symbolic.expr.fp.RealConstant) Constraint(org.evosuite.symbolic.expr.Constraint) RealConstraint(org.evosuite.symbolic.expr.RealConstraint) EvoSuiteSolver(org.evosuite.symbolic.solver.avm.EvoSuiteSolver) ArrayList(java.util.ArrayList) RealVariable(org.evosuite.symbolic.expr.fp.RealVariable) RealConstraint(org.evosuite.symbolic.expr.RealConstraint) Test(org.junit.Test)

Example 49 with EvoSuiteSolver

use of org.evosuite.symbolic.solver.avm.EvoSuiteSolver 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();
    }
}
Also used : SolverTimeoutException(org.evosuite.symbolic.solver.SolverTimeoutException) RealConstant(org.evosuite.symbolic.expr.fp.RealConstant) Constraint(org.evosuite.symbolic.expr.Constraint) RealConstraint(org.evosuite.symbolic.expr.RealConstraint) EvoSuiteSolver(org.evosuite.symbolic.solver.avm.EvoSuiteSolver) ArrayList(java.util.ArrayList) RealVariable(org.evosuite.symbolic.expr.fp.RealVariable) RealConstraint(org.evosuite.symbolic.expr.RealConstraint) Test(org.junit.Test)

Example 50 with EvoSuiteSolver

use of org.evosuite.symbolic.solver.avm.EvoSuiteSolver 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();
    }
}
Also used : SolverTimeoutException(org.evosuite.symbolic.solver.SolverTimeoutException) RealConstant(org.evosuite.symbolic.expr.fp.RealConstant) Constraint(org.evosuite.symbolic.expr.Constraint) RealConstraint(org.evosuite.symbolic.expr.RealConstraint) EvoSuiteSolver(org.evosuite.symbolic.solver.avm.EvoSuiteSolver) ArrayList(java.util.ArrayList) RealVariable(org.evosuite.symbolic.expr.fp.RealVariable) RealConstraint(org.evosuite.symbolic.expr.RealConstraint) Test(org.junit.Test)

Aggregations

Constraint (org.evosuite.symbolic.expr.Constraint)76 EvoSuiteSolver (org.evosuite.symbolic.solver.avm.EvoSuiteSolver)76 SolverTimeoutException (org.evosuite.symbolic.solver.SolverTimeoutException)74 Test (org.junit.Test)74 ArrayList (java.util.ArrayList)67 IntegerConstraint (org.evosuite.symbolic.expr.IntegerConstraint)48 IntegerConstant (org.evosuite.symbolic.expr.bv.IntegerConstant)36 SolverResult (org.evosuite.symbolic.solver.SolverResult)31 IntegerVariable (org.evosuite.symbolic.expr.bv.IntegerVariable)24 StringVariable (org.evosuite.symbolic.expr.str.StringVariable)24 StringConstraint (org.evosuite.symbolic.expr.StringConstraint)23 RealConstraint (org.evosuite.symbolic.expr.RealConstraint)22 RealVariable (org.evosuite.symbolic.expr.fp.RealVariable)21 StringConstant (org.evosuite.symbolic.expr.str.StringConstant)19 RealConstant (org.evosuite.symbolic.expr.fp.RealConstant)15 StringBinaryComparison (org.evosuite.symbolic.expr.bv.StringBinaryComparison)14 StringBinaryToIntegerExpression (org.evosuite.symbolic.expr.bv.StringBinaryToIntegerExpression)10 IntegerBinaryExpression (org.evosuite.symbolic.expr.bv.IntegerBinaryExpression)8 StringUnaryExpression (org.evosuite.symbolic.expr.str.StringUnaryExpression)5 Expression (org.evosuite.symbolic.expr.Expression)4