diff options
author | Sven Gothel <[email protected]> | 2011-02-13 14:10:11 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-02-13 14:10:11 +0100 |
commit | ed080420e9584a881ea3c50dc63b68c65bf0e67d (patch) | |
tree | 0f705724944ecd4ea16151017484304728a92b68 /src/junit/com/jogamp/common/nio/BuffersTest.java | |
parent | f92907da4946b29ca3b0132743f1cf0b7d59e080 (diff) | |
parent | 092467f806af49846e3f7beb1f44bbbf4ff02891 (diff) |
Merge remote branch 'mbien/master'
Diffstat (limited to 'src/junit/com/jogamp/common/nio/BuffersTest.java')
-rw-r--r-- | src/junit/com/jogamp/common/nio/BuffersTest.java | 33 |
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)); + } |