Creating a path with ten points (one moveTo and nine lineTos) and passing it to the constructor of an Area throws an exception:
import org.junit.Test;
import pythagoras.f.Area;
import pythagoras.f.Path;
public class BigAreaTest {
@Test
public void areaWithPath() {
Path path = new Path();
path.moveTo(0f, 0f);
for (int i = 1; i <= 8; i++) {
path.lineTo(2f * i, 3f * i);
}
Area areaWithNinePoints = new Area(path);
path.reset();
path.moveTo(0f, 0f);
for (int i = 1; i <= 10; i++) {
path.lineTo(2f * i, 3f * i);
}
Area areaWithElevenPoints = new Area(path);
path.reset();
path.moveTo(0f, 0f);
for (int i = 1; i <= 9; i++) {
path.lineTo(2f * i, 3f * i);
}
// ArrayIndexOutOfBoundsException
Area areaWithTenPoints = new Area(path);
}
}
Creating a path with ten points (one moveTo and nine lineTos) and passing it to the constructor of an Area throws an exception: