Search in sources :

Example 16 with RealConstraint

use of org.evosuite.symbolic.expr.RealConstraint 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 17 with RealConstraint

use of org.evosuite.symbolic.expr.RealConstraint 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 18 with RealConstraint

use of org.evosuite.symbolic.expr.RealConstraint 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 19 with RealConstraint

use of org.evosuite.symbolic.expr.RealConstraint 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)

Example 20 with RealConstraint

use of org.evosuite.symbolic.expr.RealConstraint 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();
    }
}
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) RealConstraint(org.evosuite.symbolic.expr.RealConstraint) Test(org.junit.Test)

Aggregations

RealConstraint (org.evosuite.symbolic.expr.RealConstraint)23 Constraint (org.evosuite.symbolic.expr.Constraint)22 RealVariable (org.evosuite.symbolic.expr.fp.RealVariable)22 ArrayList (java.util.ArrayList)21 SolverTimeoutException (org.evosuite.symbolic.solver.SolverTimeoutException)21 EvoSuiteSolver (org.evosuite.symbolic.solver.avm.EvoSuiteSolver)21 Test (org.junit.Test)20 RealConstant (org.evosuite.symbolic.expr.fp.RealConstant)16 RealBinaryExpression (org.evosuite.symbolic.expr.fp.RealBinaryExpression)2 DistanceCalculator (org.evosuite.symbolic.expr.DistanceCalculator)1 IntegerConstraint (org.evosuite.symbolic.expr.IntegerConstraint)1 StringConstraint (org.evosuite.symbolic.expr.StringConstraint)1