### Question:
HugeArrays { public static long oversize(long minTargetSize, int bytesPerElement) { if (minTargetSize == 0) { return 0; } long extra = minTargetSize >> 3; if (extra < 3) { extra = 3; } long newSize = minTargetSize + extra; if (MemoryUsage.BYTES_OBJECT_REF == 8) { switch (bytesPerElement) { case 4: return (newSize + 1) & 0x7FFF_FFFE; case 2: return (newSize + 3) & 0x7FFF_FFFC; case 1: return (newSize + 7) & 0x7FFF_FFF8; case 8: default: return newSize; } } else { switch (bytesPerElement) { case 2: return (newSize + 1) & 0x7FFFFFFE; case 1: return (newSize + 3) & 0x7FFFFFFC; case 4: case 8: default: return newSize; } } } private  HugeArrays(); static long oversize(long minTargetSize, int bytesPerElement);  }### Answer:
@Test void oversizeIncreasesBy1over8() { var actual = oversize(8 * 42, Integer.BYTES); assertEquals(9 * 42, actual); }
@Test void oversizeDoesWorkWithHugeArraySizes() { var actual = oversize(1L << 42L, Integer.BYTES); assertEquals((1L << 42L) + (1L << 39L), actual); }
@Test void oversizeHasMinGrowthForSmallSizes() { var actual = oversize(1, Integer.BYTES); assertEquals(4, actual); }
@Test void oversizeDoesntGrowForEmptyArrays() { var actual = oversize(0, Integer.BYTES); assertEquals(0, actual); }
@Test void oversizeAlignsToPointerSize() { var actual = oversize(42, Byte.BYTES); assertEquals(48, actual); }