Search in sources :

Example 1 with StringToIntegerCast

use of org.evosuite.symbolic.expr.bv.StringToIntegerCast in project evosuite by EvoSuite.

the class I_ParseInt method executeFunction.

@Override
public Object executeFunction() {
    ReferenceConstant symb_string_ref = (ReferenceConstant) this.getSymbArgument(0);
    String conc_string = (String) this.getConcArgument(0);
    int conc_integer = this.getConcIntRetVal();
    StringValue symb_string_value = env.heap.getField(org.evosuite.symbolic.vm.regex.Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_string, symb_string_ref, conc_string);
    long longValue = (long) conc_integer;
    StringToIntegerCast parse_int_value = new StringToIntegerCast(symb_string_value, longValue);
    return parse_int_value;
}
Also used : ReferenceConstant(org.evosuite.symbolic.expr.ref.ReferenceConstant) StringToIntegerCast(org.evosuite.symbolic.expr.bv.StringToIntegerCast) StringValue(org.evosuite.symbolic.expr.str.StringValue) IntegerConstraint(org.evosuite.symbolic.expr.IntegerConstraint)

Example 2 with StringToIntegerCast

use of org.evosuite.symbolic.expr.bv.StringToIntegerCast in project evosuite by EvoSuite.

the class TestConstraintSolver3 method buildConstraintSystem.

private static Collection<Constraint<?>> buildConstraintSystem() {
    StringVariable var0 = new StringVariable("var0", INIT_STRING);
    StringToIntegerCast castStr = new StringToIntegerCast(var0, (long) Integer.parseInt(INIT_STRING));
    IntegerConstant const126 = new IntegerConstant(EXPECTED_INTEGER);
    IntegerConstraint constr1 = new IntegerConstraint(castStr, Comparator.EQ, const126);
    return Arrays.<Constraint<?>>asList(constr1);
}
Also used : IntegerConstraint(org.evosuite.symbolic.expr.IntegerConstraint) IntegerConstraint(org.evosuite.symbolic.expr.IntegerConstraint) Constraint(org.evosuite.symbolic.expr.Constraint) StringToIntegerCast(org.evosuite.symbolic.expr.bv.StringToIntegerCast) StringVariable(org.evosuite.symbolic.expr.str.StringVariable) IntegerConstant(org.evosuite.symbolic.expr.bv.IntegerConstant)

Example 3 with StringToIntegerCast

use of org.evosuite.symbolic.expr.bv.StringToIntegerCast in project evosuite by EvoSuite.

the class BigInteger_Ctor method executeFunction.

@Override
public Object executeFunction() {
    String conc_string = (String) this.getConcArgument(0);
    ReferenceConstant str_ref = (ReferenceConstant) this.getSymbArgument(0);
    StringValue symb_string = this.env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_string, str_ref, conc_string);
    if (symb_string.containsSymbolicVariable()) {
        ReferenceConstant symb_big_integer = (ReferenceConstant) env.topFrame().operandStack.peekRef();
        BigInteger bigInteger = new BigInteger(conc_string);
        long concVal = bigInteger.longValue();
        StringToIntegerCast big_integer_value = new StringToIntegerCast(symb_string, concVal);
        env.heap.putField(Types.JAVA_MATH_BIG_INTEGER, SymbolicHeap.$BIG_INTEGER_CONTENTS, null, /* conc_big_integer */
        symb_big_integer, big_integer_value);
    }
    // return void
    return null;
}
Also used : ReferenceConstant(org.evosuite.symbolic.expr.ref.ReferenceConstant) StringToIntegerCast(org.evosuite.symbolic.expr.bv.StringToIntegerCast) BigInteger(java.math.BigInteger) StringValue(org.evosuite.symbolic.expr.str.StringValue)

Aggregations

StringToIntegerCast (org.evosuite.symbolic.expr.bv.StringToIntegerCast)3 IntegerConstraint (org.evosuite.symbolic.expr.IntegerConstraint)2 ReferenceConstant (org.evosuite.symbolic.expr.ref.ReferenceConstant)2 StringValue (org.evosuite.symbolic.expr.str.StringValue)2 BigInteger (java.math.BigInteger)1 Constraint (org.evosuite.symbolic.expr.Constraint)1 IntegerConstant (org.evosuite.symbolic.expr.bv.IntegerConstant)1 StringVariable (org.evosuite.symbolic.expr.str.StringVariable)1