EvoSuite / evosuite

EvoSuite - automated generation of JUnit test suites for Java classes
http://www.evosuite.org
GNU Lesser General Public License v3.0
829 stars 340 forks source link

test fail: ArrayIndexOutOfBoundsException #389

Open suoyi123wang opened 2 years ago

suoyi123wang commented 2 years ago

for the method ofClassFile image

we generate a unit test for it image

saiema commented 2 years ago

If binaryRepresentation has length 7, then the last accessible index is 6, so the binaryRepresentation[7] & 255 will throw an ArrayOutOfBoundsException when the length is exactly 7.

In Java, array indexes go from 0 to array.length - 1

Although I think that EvoSuite should generate a test saying that calling ofClassFile(a) with a an array of size 7, is expected to throw an exception.