summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2011-02-13 13:40:35 +0100
committerMichael Bien <[email protected]>2011-02-13 13:40:35 +0100
commit092467f806af49846e3f7beb1f44bbbf4ff02891 (patch)
tree7a6b2cd598f2de39846f3735f6e1b9e4ba7b832e
parent34c2dd10e652df8d1062fd868599241564975cd5 (diff)
improved BuffersTest.slice().
-rw-r--r--src/junit/com/jogamp/common/nio/BuffersTest.java33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/junit/com/jogamp/common/nio/BuffersTest.java b/src/junit/com/jogamp/common/nio/BuffersTest.java
index 0b72cd4..836e46d 100644
--- a/src/junit/com/jogamp/common/nio/BuffersTest.java
+++ b/src/junit/com/jogamp/common/nio/BuffersTest.java
@@ -43,14 +43,45 @@ public class BuffersTest {
@Test
public void slice() {
+
IntBuffer buffer = Buffers.newDirectIntBuffer(6);
buffer.put(new int[]{1,2,3,4,5,6}).rewind();
- IntBuffer threefour = (IntBuffer)Buffers.slice(buffer, 2, 2);
+ IntBuffer threefour = Buffers.slice(buffer, 2, 2);
assertEquals(3, threefour.get(0));
assertEquals(4, threefour.get(1));
assertEquals(2, threefour.capacity());
+
+ assertEquals(0, buffer.position());
+ assertEquals(6, buffer.limit());
+
+ IntBuffer fourfivesix = Buffers.slice(buffer, 3, 3);
+
+ assertEquals(4, fourfivesix.get(0));
+ assertEquals(5, fourfivesix.get(1));
+ assertEquals(6, fourfivesix.get(2));
+ assertEquals(3, fourfivesix.capacity());
+
+ assertEquals(0, buffer.position());
+ assertEquals(6, buffer.limit());
+
+ IntBuffer onetwothree = Buffers.slice(buffer, 0, 3);
+
+ assertEquals(1, onetwothree.get(0));
+ assertEquals(2, onetwothree.get(1));
+ assertEquals(3, onetwothree.get(2));
+ assertEquals(3, onetwothree.capacity());
+
+ assertEquals(0, buffer.position());
+ assertEquals(6, buffer.limit());
+
+ // is it really sliced?
+ buffer.put(2, 42);
+
+ assertEquals(42, buffer.get(2));
+ assertEquals(42, onetwothree.get(2));
+
}