summaryrefslogtreecommitdiffstats
path: root/luni/src/test/java/libcore/java/nio/BufferTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'luni/src/test/java/libcore/java/nio/BufferTest.java')
-rw-r--r--luni/src/test/java/libcore/java/nio/BufferTest.java76
1 files changed, 76 insertions, 0 deletions
diff --git a/luni/src/test/java/libcore/java/nio/BufferTest.java b/luni/src/test/java/libcore/java/nio/BufferTest.java
index 06a8e94..2a895fc 100644
--- a/luni/src/test/java/libcore/java/nio/BufferTest.java
+++ b/luni/src/test/java/libcore/java/nio/BufferTest.java
@@ -675,4 +675,80 @@ public class BufferTest extends TestCase {
}
assertFalse(bb.hasArray());
}
+
+ public void testBug6085292() {
+ ByteBuffer b = ByteBuffer.allocateDirect(1);
+
+ try {
+ b.asCharBuffer().get();
+ fail();
+ } catch (BufferUnderflowException expected) {
+ }
+ try {
+ b.asCharBuffer().get(0);
+ fail();
+ } catch (IndexOutOfBoundsException expected) {
+ assertTrue(expected.getMessage().contains("limit=0"));
+ }
+
+ try {
+ b.asDoubleBuffer().get();
+ fail();
+ } catch (BufferUnderflowException expected) {
+ }
+ try {
+ b.asDoubleBuffer().get(0);
+ fail();
+ } catch (IndexOutOfBoundsException expected) {
+ assertTrue(expected.getMessage().contains("limit=0"));
+ }
+
+ try {
+ b.asFloatBuffer().get();
+ fail();
+ } catch (BufferUnderflowException expected) {
+ }
+ try {
+ b.asFloatBuffer().get(0);
+ fail();
+ } catch (IndexOutOfBoundsException expected) {
+ assertTrue(expected.getMessage().contains("limit=0"));
+ }
+
+ try {
+ b.asIntBuffer().get();
+ fail();
+ } catch (BufferUnderflowException expected) {
+ }
+ try {
+ b.asIntBuffer().get(0);
+ fail();
+ } catch (IndexOutOfBoundsException expected) {
+ assertTrue(expected.getMessage().contains("limit=0"));
+ }
+
+ try {
+ b.asLongBuffer().get();
+ fail();
+ } catch (BufferUnderflowException expected) {
+ }
+ try {
+ b.asLongBuffer().get(0);
+ fail();
+ } catch (IndexOutOfBoundsException expected) {
+ assertTrue(expected.getMessage().contains("limit=0"));
+ }
+
+ try {
+ b.asShortBuffer().get();
+ fail();
+ } catch (BufferUnderflowException expected) {
+ }
+ try {
+ b.asShortBuffer().get(0);
+ fail();
+ } catch (IndexOutOfBoundsException expected) {
+ assertTrue(expected.getMessage().contains("limit=0"));
+ }
+ }
}