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 | |
parent | f92907da4946b29ca3b0132743f1cf0b7d59e080 (diff) | |
parent | 092467f806af49846e3f7beb1f44bbbf4ff02891 (diff) |
Merge remote branch 'mbien/master'
Diffstat (limited to 'src/junit')
-rw-r--r-- | src/junit/com/jogamp/common/nio/BuffersTest.java | 33 | ||||
-rw-r--r-- | src/junit/com/jogamp/common/nio/TestPointerBufferEndian.java (renamed from src/junit/com/jogamp/gluegen/test/junit/runtime/TestPointerBufferEndian.java) | 13 | ||||
-rw-r--r-- | src/junit/com/jogamp/common/nio/TestStructAccessorEndian.java (renamed from src/junit/com/jogamp/gluegen/test/junit/runtime/TestStructAccessorEndian.java) | 10 |
3 files changed, 40 insertions, 16 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)); + } diff --git a/src/junit/com/jogamp/gluegen/test/junit/runtime/TestPointerBufferEndian.java b/src/junit/com/jogamp/common/nio/TestPointerBufferEndian.java index afe3405..da232a2 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/runtime/TestPointerBufferEndian.java +++ b/src/junit/com/jogamp/common/nio/TestPointerBufferEndian.java @@ -1,14 +1,9 @@ -package com.jogamp.gluegen.test.junit.runtime; +package com.jogamp.common.nio; -import com.jogamp.common.nio.*; import com.jogamp.common.os.*; -import java.nio.*; - import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; import static java.lang.System.*; @@ -20,9 +15,9 @@ public class TestPointerBufferEndian { String bitsProp = System.getProperty("sun.arch.data.model"); String os = System.getProperty("os.name"); String cpu = System.getProperty("os.arch"); - System.out.println("OS: <"+os+"> CPU: <"+cpu+"> Bits: <"+bitsPtr+"/"+bitsProp+">"); - System.out.println("CPU is: "+ (Platform.is32Bit()?"32":"64") + " bit"); - System.out.println("Buffer is in: "+ (Platform.isLittleEndian()?"little":"big") + " endian"); + out.println("OS: <"+os+"> CPU: <"+cpu+"> Bits: <"+bitsPtr+"/"+bitsProp+">"); + out.println("CPU is: "+ (Platform.is32Bit()?"32":"64") + " bit"); + out.println("Buffer is in: "+ (Platform.isLittleEndian()?"little":"big") + " endian"); long[] valuesSource = { 0x0123456789ABCDEFL, 0x8877665544332211L, 0xAFFEDEADBEEFAFFEL }; long[] values32Bit = { 0x0000000089ABCDEFL, 0x0000000044332211L, 0x00000000BEEFAFFEL }; diff --git a/src/junit/com/jogamp/gluegen/test/junit/runtime/TestStructAccessorEndian.java b/src/junit/com/jogamp/common/nio/TestStructAccessorEndian.java index 264c86b..09781ec 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/runtime/TestStructAccessorEndian.java +++ b/src/junit/com/jogamp/common/nio/TestStructAccessorEndian.java @@ -1,4 +1,4 @@ -package com.jogamp.gluegen.test.junit.runtime; +package com.jogamp.common.nio; import com.jogamp.common.nio.*; import com.jogamp.common.os.*; @@ -6,8 +6,6 @@ import com.jogamp.common.os.*; import java.nio.*; import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; import static java.lang.System.*; @@ -20,9 +18,9 @@ public class TestStructAccessorEndian { String bitsProp = System.getProperty("sun.arch.data.model"); String os = System.getProperty("os.name"); String cpu = System.getProperty("os.arch"); - System.out.println("OS: <"+os+"> CPU: <"+cpu+"> Bits: <"+bitsPtr+"/"+bitsProp+">"); - System.out.println("CPU is: "+ (Platform.is32Bit()?"32":"64") + " bit"); - System.out.println("Buffer is in: "+ (Platform.isLittleEndian()?"little":"big") + " endian"); + out.println("OS: <"+os+"> CPU: <"+cpu+"> Bits: <"+bitsPtr+"/"+bitsProp+">"); + out.println("CPU is: "+ (Platform.is32Bit()?"32":"64") + " bit"); + out.println("Buffer is in: "+ (Platform.isLittleEndian()?"little":"big") + " endian"); long[] valuesSource = { 0x0123456789ABCDEFL, 0x8877665544332211L, 0xAFFEDEADBEEFAFFEL }; ByteBuffer tst = Buffers.newDirectByteBuffer(Buffers.SIZEOF_LONG * valuesSource.length); |