aboutsummaryrefslogtreecommitdiffstats
path: root/src/junit/com/jogamp/common/nio/TestStructAccessorEndian.java
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2011-02-13 13:23:21 +0100
committerMichael Bien <[email protected]>2011-02-13 13:23:21 +0100
commit21e0b226492fe1db0126528c5fddfb29d222a9cd (patch)
treeb9e6472d8e700735ba74c90771951c7b81c9ad56 /src/junit/com/jogamp/common/nio/TestStructAccessorEndian.java
parent7a1e5564a4ad86d0b122c056a71373bbeb472be6 (diff)
moved struct and buffer test to its nio friends, cleaned up imports
Diffstat (limited to 'src/junit/com/jogamp/common/nio/TestStructAccessorEndian.java')
-rw-r--r--src/junit/com/jogamp/common/nio/TestStructAccessorEndian.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/junit/com/jogamp/common/nio/TestStructAccessorEndian.java b/src/junit/com/jogamp/common/nio/TestStructAccessorEndian.java
new file mode 100644
index 0000000..09781ec
--- /dev/null
+++ b/src/junit/com/jogamp/common/nio/TestStructAccessorEndian.java
@@ -0,0 +1,41 @@
+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.Test;
+
+import static java.lang.System.*;
+
+public class TestStructAccessorEndian {
+
+ @Test
+ public void testStructAccessorEndian1 () {
+ int bitsPtr = Platform.getPointerSizeInBits();
+ String bitsProp = System.getProperty("sun.arch.data.model");
+ String os = System.getProperty("os.name");
+ String cpu = System.getProperty("os.arch");
+ 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);
+ StructAccessor acc = new StructAccessor(tst);
+
+ int i;
+
+ for(i=0; i<valuesSource.length; i++) {
+ acc.setLongAt(i, valuesSource[i]);
+ }
+
+ for(i=0; i<valuesSource.length; i++) {
+ long v = acc.getLongAt(i);
+ long t = valuesSource[i];
+ Assert.assertTrue("Value["+i+"] shall be 0x"+Long.toHexString(t)+", is: 0x"+Long.toHexString(v), t == v);
+ }
+ }
+}