### Question:
BoundedProportionalArraySizingStrategy implements ArraySizingStrategy { public int grow(int currentBufferLength, int elementsCount, int expectedAdditions) { long growBy = (long) ((long) currentBufferLength * growRatio); growBy = Math.max(growBy, minGrowCount); growBy = Math.min(growBy, maxGrowCount); long growTo = Math.min(MAX_ARRAY_LENGTH, growBy + currentBufferLength); long newSize = Math.max((long) elementsCount + expectedAdditions, growTo); if (newSize > MAX_ARRAY_LENGTH) { throw new BufferAllocationException( "Java array size exceeded (current length: %d, elements: %d, expected additions: %d)", currentBufferLength, elementsCount, expectedAdditions); } return (int) newSize; } BoundedProportionalArraySizingStrategy();  BoundedProportionalArraySizingStrategy(int minGrow, int maxGrow, float ratio); int grow(int currentBufferLength, int elementsCount, int expectedAdditions); static final int MAX_ARRAY_LENGTH; static final int DEFAULT_MIN_GROW_COUNT; static final int DEFAULT_MAX_GROW_COUNT; static final float DEFAULT_GROW_RATIO; final int minGrowCount; final int maxGrowCount; final float growRatio; }### Answer:
@Test(expected = BufferAllocationException.class) public void testBeyondIntRange() { resizer = new BoundedProportionalArraySizingStrategy(); resizer.grow( BoundedProportionalArraySizingStrategy.MAX_ARRAY_LENGTH, BoundedProportionalArraySizingStrategy.MAX_ARRAY_LENGTH, 1); }
@Test public void testExactIntRange() { resizer = new BoundedProportionalArraySizingStrategy(); int size = BoundedProportionalArraySizingStrategy.MAX_ARRAY_LENGTH - 2; size = resizer.grow(size, size, 1); assertEquals(BoundedProportionalArraySizingStrategy.MAX_ARRAY_LENGTH, size); try { size = resizer.grow(size, size, 1); throw new RuntimeException("Unexpected."); } catch (BufferAllocationException e) { } }