### Question:
HugeArrays { static int indexInPage(long index) { return (int) (index & PAGE_MASK); } private  HugeArrays(); static long oversize(long minTargetSize, int bytesPerElement);  }### Answer:
@Test void indexInPageOnFirstPage() { assertEquals(0L, indexInPage(0L)); assertEquals(1L, indexInPage(1L)); assertEquals(PAGE_SIZE - 1L, indexInPage(PAGE_SIZE - 1L)); }
@Test void indexInPageOnSecondPage() { assertEquals(0L, indexInPage(PAGE_SIZE)); assertEquals(1L, indexInPage(PAGE_SIZE + 1L)); assertEquals(PAGE_SIZE - 1L, indexInPage(2 * PAGE_SIZE - 1L)); }
@Test void indexInPageOfMaxPage() { assertEquals(0L, indexInPage((long) Integer.MAX_VALUE * PAGE_SIZE)); assertEquals(PAGE_SIZE - 1L, indexInPage((long) Integer.MAX_VALUE * PAGE_SIZE + PAGE_SIZE - 1L)); }
@Test void indexInPageWhenIndexIsTooLarge() { assertEquals(0L, indexInPage(1L << 62)); assertEquals(PAGE_SIZE - 1L, indexInPage(Long.MAX_VALUE)); }
@Test void indexInPageForNegativeIndex() { assertEquals(PAGE_SIZE - 1L, indexInPage(-1L)); assertEquals(PAGE_SIZE - 2L, indexInPage(-2L)); assertEquals(0L, indexInPage(Long.MIN_VALUE)); }