Search in sources :

Example 66 with ReferenceConstant

use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.

the class StringBuilder_ToString method executeFunction.

@Override
public Object executeFunction() {
    ReferenceConstant symb_str_builder = (ReferenceConstant) this.getSymbReceiver();
    // receiver
    StringBuilder conc_str_builder = (StringBuilder) this.getConcReceiver();
    // return value
    String res = (String) this.getConcRetVal();
    if (res != null) {
        ReferenceConstant symb_ret_val = (ReferenceConstant) this.getSymbRetVal();
        StringValue symb_value = env.heap.getField(Types.JAVA_LANG_STRING_BUILDER, SymbolicHeap.$STRING_BUILDER_CONTENTS, conc_str_builder, symb_str_builder, conc_str_builder.toString());
        String conc_receiver = (String) res;
        env.heap.putField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_receiver, symb_ret_val, symb_value);
    }
    return this.getSymbRetVal();
}
Also used : ReferenceConstant(org.evosuite.symbolic.expr.ref.ReferenceConstant) StringValue(org.evosuite.symbolic.expr.str.StringValue)

Example 67 with ReferenceConstant

use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.

the class HasMoreTokens method executeFunction.

@Override
public Object executeFunction() {
    StringTokenizer conc_tokenizer = (StringTokenizer) this.getConcReceiver();
    ReferenceConstant symb_tokenizer = this.getSymbReceiver();
    boolean res = this.getConcBooleanRetVal();
    TokenizerExpr tokenizerExpr = (TokenizerExpr) env.heap.getField(Types.JAVA_UTIL_STRING_TOKENIZER, SymbolicHeap.$STRING_TOKENIZER_VALUE, conc_tokenizer, symb_tokenizer);
    if (tokenizerExpr != null && tokenizerExpr.containsSymbolicVariable()) {
        HasMoreTokensExpr hasMoreTokenExpr = new HasMoreTokensExpr(tokenizerExpr, (long) (res ? 1L : 0L));
        return hasMoreTokenExpr;
    }
    return this.getSymbIntegerRetVal();
}
Also used : ReferenceConstant(org.evosuite.symbolic.expr.ref.ReferenceConstant) StringTokenizer(java.util.StringTokenizer) HasMoreTokensExpr(org.evosuite.symbolic.expr.token.HasMoreTokensExpr) TokenizerExpr(org.evosuite.symbolic.expr.token.TokenizerExpr)

Example 68 with ReferenceConstant

use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.

the class StringTokenizer_Init method executeFunction.

@Override
public Object executeFunction() {
    // symbolic receiver (new object)
    ReferenceConstant symb_str_tokenizer = (ReferenceConstant) this.getSymbReceiver();
    // string argument
    String conc_str = (String) this.getConcArgument(0);
    ReferenceExpression symb_str = this.getSymbArgument(0);
    // delim argument
    String conc_delim = (String) this.getConcArgument(1);
    ReferenceExpression symb_delim = this.getSymbArgument(1);
    if (symb_str instanceof ReferenceConstant && symb_delim instanceof ReferenceConstant) {
        ReferenceConstant non_null_symb_string = (ReferenceConstant) symb_str;
        assert conc_str != null;
        StringValue strExpr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_str, non_null_symb_string, conc_str);
        ReferenceConstant non_null_symb_delim = (ReferenceConstant) symb_delim;
        assert conc_delim != null;
        StringValue delimExpr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_delim, non_null_symb_delim, conc_delim);
        NewTokenizerExpr newTokenizerExpr = new NewTokenizerExpr(strExpr, delimExpr);
        // update symbolic heap
        env.heap.putField(Types.JAVA_UTIL_STRING_TOKENIZER, SymbolicHeap.$STRING_TOKENIZER_VALUE, null, symb_str_tokenizer, newTokenizerExpr);
    }
    // constructor returns void
    return null;
}
Also used : ReferenceConstant(org.evosuite.symbolic.expr.ref.ReferenceConstant) NewTokenizerExpr(org.evosuite.symbolic.expr.token.NewTokenizerExpr) ReferenceExpression(org.evosuite.symbolic.expr.ref.ReferenceExpression) StringValue(org.evosuite.symbolic.expr.str.StringValue)

Example 69 with ReferenceConstant

use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.

the class B_Init method executeFunction.

@Override
public Object executeFunction() {
    IntegerValue bv32 = this.getSymbIntegerArgument(0);
    ReferenceConstant symb_byte = (ReferenceConstant) this.getSymbReceiver();
    env.heap.putField(Types.JAVA_LANG_BYTE, SymbolicHeap.$BYTE_VALUE, null, /* conc_integer */
    symb_byte, bv32);
    // return void
    return null;
}
Also used : ReferenceConstant(org.evosuite.symbolic.expr.ref.ReferenceConstant) IntegerValue(org.evosuite.symbolic.expr.bv.IntegerValue)

Example 70 with ReferenceConstant

use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.

the class C_CharValue method executeFunction.

@Override
public Object executeFunction() {
    ReferenceConstant symb_character = this.getSymbReceiver();
    Character conc_character = (Character) this.getConcReceiver();
    char conc_char_value = this.getConcCharRetVal();
    IntegerValue symb_char_value = env.heap.getField(Types.JAVA_LANG_CHARACTER, SymbolicHeap.$CHAR_VALUE, conc_character, symb_character, conc_char_value);
    return symb_char_value;
}
Also used : ReferenceConstant(org.evosuite.symbolic.expr.ref.ReferenceConstant) IntegerValue(org.evosuite.symbolic.expr.bv.IntegerValue)

Aggregations

ReferenceConstant (org.evosuite.symbolic.expr.ref.ReferenceConstant)99 StringValue (org.evosuite.symbolic.expr.str.StringValue)39 IntegerValue (org.evosuite.symbolic.expr.bv.IntegerValue)32 ReferenceExpression (org.evosuite.symbolic.expr.ref.ReferenceExpression)18 CodeUnderTestException (org.evosuite.testcase.execution.CodeUnderTestException)16 VariableReference (org.evosuite.testcase.variable.VariableReference)14 Type (org.objectweb.asm.Type)12 RealValue (org.evosuite.symbolic.expr.fp.RealValue)11 EvosuiteError (org.evosuite.testcase.execution.EvosuiteError)11 Expression (org.evosuite.symbolic.expr.Expression)9 StringBinaryComparison (org.evosuite.symbolic.expr.bv.StringBinaryComparison)8 IntegerVariable (org.evosuite.symbolic.expr.bv.IntegerVariable)6 PrimitiveExpression (org.evosuite.testcase.statements.PrimitiveExpression)5 StringConstant (org.evosuite.symbolic.expr.str.StringConstant)4 BigInteger (java.math.BigInteger)3 ArrayList (java.util.ArrayList)3 IntegerConstraint (org.evosuite.symbolic.expr.IntegerConstraint)3 IntegerConstant (org.evosuite.symbolic.expr.bv.IntegerConstant)3 StringBinaryToIntegerExpression (org.evosuite.symbolic.expr.bv.StringBinaryToIntegerExpression)3 StringReaderExpr (org.evosuite.symbolic.expr.reader.StringReaderExpr)3