@Test public void shouldAlignToWordBoundary() { final int capacity = 128; final ByteBuffer byteBuffer = BufferUtil.allocateDirectAligned(capacity, SIZE_OF_LONG); final long address = BufferUtil.address(byteBuffer); assertTrue(isAligned(address, SIZE_OF_LONG)); assertThat(byteBuffer.capacity(), is(capacity)); }
@Test public void shouldAlignToCacheLineBoundary() { final int capacity = 128; final ByteBuffer byteBuffer = BufferUtil.allocateDirectAligned(capacity, CACHE_LINE_LENGTH); final long address = BufferUtil.address(byteBuffer); assertTrue(isAligned(address, CACHE_LINE_LENGTH)); assertThat(byteBuffer.capacity(), is(capacity)); } }