Open
Description
Description
Engine generates 7 executions for this method, but doesn't cover "else" branch for condition (cs1 instanceof String && cs2 instanceof String).
public static boolean equals(CharSequence cs1, CharSequence cs2) {
if (cs1 == cs2) {
return true;
} else if (cs1 != null && cs2 != null) {
if (cs1.length() != cs2.length()) {
return false;
} else if (cs1 instanceof String && cs2 instanceof String) {
return cs1.equals(cs2);
} else {
// Engine never comes into this branch
int length = cs1.length();
for(int i = 0; i < length; ++i) {
if (cs1.charAt(i) != cs2.charAt(i)) {
return false;
}
}
return true;
}
} else {
return false;
}
}
It happens because of wrappers: we create an object with the only type and concrete implementation. Therefore we don't have any type to !instanceof
branch. So we have to work with them both with concrete implementation and without. When we face instanceof
instruction, we should use concrete in true
branch, otherwise use pure symbolic version
To Reproduce
Steps to reproduce the behavior:
- Create the mentioned method
- Use plugin to generate tests
- Open the generated test
- Run tests with coverage
Expected behavior
All branches are covered.
Actual behavior
There is uncovered branch.
Visual proofs (screenshots, logs, images)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
In Progress