Skip to content

Assemble model is not created for class with array field #361

Closed
@EgorkaKulikov

Description

@EgorkaKulikov

Description

Consider the following class

public class CashCoder {
    private int[] value /*= new int[0]*/;

    public CashCoder() { }

    public CashCoder(int[] value) {
        this.value = value;
    }

    public int cashCode() {
        int result = 0;
        for (int i : value) {
            result = 31 * result + i;
        }
        if (result == 42 && value.length > 1 && value[0] > 0) throw new RuntimeException("It's forty two!");
        return result;
    }
}

Tests, generated for cashCode method, should use constructor, but creating an instance with reflection is actually called

Expected behavior

Tests are something like this:

@Test
@DisplayName("cashCode: result == 42 : False -> return result")
public void testCashCode_ResultNotEquals42() {
    int[] intArray = {};
    CashCoder cashCoder = new CashCoder(intArray);

    int actual = cashCoder.cashCode();

    assertEquals(0, actual);
}

Metadata

Metadata

Assignees

Labels

comp-symbolic-engineIssue is related to the symbolic execution enginectg-bugIssue is a bugpriority-top-focusTop priority chosen by dev team

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions