### Question:
CompressedLongArray { void ensureCapacity(int pos, int required, byte[] storage) { int targetLength = pos + required; if (targetLength < 0) { throw new IllegalArgumentException(formatWithLocale( "Encountered numeric overflow in internal buffer. Was at position %d and needed to grow by %d.", pos, required )); } else if (storage.length <= targetLength) { int newLength = ArrayUtil.oversize(targetLength, Byte.BYTES); tracker.remove(sizeOfByteArray(storage.length)); tracker.add(sizeOfByteArray(newLength)); this.storage = Arrays.copyOf(storage, newLength); } } CompressedLongArray(AllocationTracker tracker);  CompressedLongArray(AllocationTracker tracker, int numberOfProperties); void add(long[] values, int start, int end, int valuesToAdd); void add(long[] values, long[][] allWeights, int start, int end, int valuesToAdd); int length(); int uncompress(long[] into); byte[] storage(); boolean hasWeights(); void release();  }### Answer:
@Test void throwsOnOverflowInEnsureCapacity() { CompressedLongArray longArray = new CompressedLongArray(AllocationTracker.empty()); var e = assertThrows( IllegalArgumentException.class, () -> { int almostIntMax = 2147483622; givenAnByteArrayOfUnsafeFakeLength(almostIntMax, data -> { longArray.ensureCapacity(almostIntMax, 100, data); }); } ); assertTrue(e.getMessage().contains("numeric overflow in internal buffer")); }