Skip to content

Instantly share code, notes, and snippets.

@jacques-n
Last active February 23, 2019 17:15
Show Gist options
  • Save jacques-n/737c26b7016ed29dc710d4aba617340e to your computer and use it in GitHub Desktop.
Save jacques-n/737c26b7016ed29dc710d4aba617340e to your computer and use it in GitHub Desktop.
Example failure of slice boundary
import static org.junit.Assert.assertEquals;
import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.memory.RootAllocator;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import io.netty.buffer.ArrowBuf;
public class TestSliceBoundary {
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void ensureOversizedSliceFail() {
try (BufferAllocator allocator = new RootAllocator(128);
ArrowBuf buf = allocator.buffer(2);
){
assertEquals(2, buf.capacity());
thrown.expect(IllegalArgumentException.class);
// should fail but doesn't.
buf.slice(0, 3);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment