FreeListManager { static void verifyHugeMultiple(int hugeMultiple) { if (hugeMultiple > 256 || hugeMultiple < 0) { throw new IllegalStateException( "HUGE_MULTIPLE must be >= 0 and <= 256 but it was " + hugeMultiple); } } FreeListManager(MemoryAllocatorImpl ma, final Slab[] slabs); long getUsedMemory(); long getFreeMemory(); @SuppressWarnings("synthetic-access") OffHeapStoredObject allocate(int size); @SuppressWarnings("synthetic-access") void free(long addr); static final int TINY_MULTIPLE; static final int TINY_FREE_LIST_COUNT; static final int HUGE_MULTIPLE; static final int MAX_TINY; }
@Test public void hugeMultipleLessThanZeroIsIllegal() { try { FreeListManager.verifyHugeMultiple(-1); fail("expected IllegalStateException"); } catch (IllegalStateException expected) { assertThat(expected.getMessage()).contains( "HUGE_MULTIPLE must be >= 0 and <= " + FreeListManager.HUGE_MULTIPLE + " but it was -1"); } }
@Test public void hugeMultipleGreaterThan256IsIllegal() { try { FreeListManager.verifyHugeMultiple(257); fail("expected IllegalStateException"); } catch (IllegalStateException expected) { assertThat(expected.getMessage()) .contains("HUGE_MULTIPLE must be >= 0 and <= 256 but it was 257"); } }
@Test public void hugeMultipleof256IsLegal() { FreeListManager.verifyHugeMultiple(256); }