diff options
Diffstat (limited to 'src/junit/com/jogamp')
14 files changed, 128 insertions, 31 deletions
diff --git a/src/junit/com/jogamp/gluegen/test/junit/BaseTest1.java b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseTest1.java index b4f8536..b689e6d 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/BaseTest1.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseTest1.java @@ -30,7 +30,7 @@ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. */ -package com.jogamp.gluegen.test.junit; +package com.jogamp.gluegen.test.junit.generation; import com.jogamp.common.nio.Buffers; import com.jogamp.common.nio.PointerBuffer; @@ -52,7 +52,7 @@ import org.junit.BeforeClass; import org.junit.Test; import static java.lang.System.*; -import static com.jogamp.gluegen.test.junit.BuildEnvironment.*; +import static com.jogamp.gluegen.test.junit.generation.BuildEnvironment.*; /** * @author Michael Bien @@ -64,8 +64,8 @@ public class BaseTest1 { * Verifies the existence and creation of the generated class. */ public void testClassExist(String name) throws Exception { - String ifName = "com.jogamp.gluegen.test.junit.Binding"+name; - String implName = "com.jogamp.gluegen.test.junit.impl.Binding"+name+"Impl"; + String ifName = "com.jogamp.gluegen.test.junit.generation.Binding"+name; + String implName = "com.jogamp.gluegen.test.junit.generation.impl.Binding"+name+"Impl"; Class<?> clazzIf = Class.forName(ifName); Class<?> clazzImpl = Class.forName(implName); @@ -77,7 +77,7 @@ public class BaseTest1 { Object obj = clazzImpl.newInstance(); Assert.assertTrue("Not of type "+ifName, clazzIf.isAssignableFrom(obj.getClass())); - Assert.assertTrue("Not of type com.jogamp.gluegen.test.junit.BindingTest1", (obj instanceof com.jogamp.gluegen.test.junit.BindingTest1)); + Assert.assertTrue("Not of type com.jogamp.gluegen.test.junit.generation.BindingTest1", (obj instanceof com.jogamp.gluegen.test.junit.generation.BindingTest1)); } /** diff --git a/src/junit/com/jogamp/gluegen/test/junit/BuildEnvironment.java b/src/junit/com/jogamp/gluegen/test/junit/generation/BuildEnvironment.java index 16d5053..db5581d 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/BuildEnvironment.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BuildEnvironment.java @@ -30,7 +30,7 @@ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. */ -package com.jogamp.gluegen.test.junit; +package com.jogamp.gluegen.test.junit.generation; import java.io.File; import java.net.URISyntaxException; diff --git a/src/junit/com/jogamp/gluegen/test/junit/Test1p1JavaEmitter.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java index c5ef4ad..6320f92 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/Test1p1JavaEmitter.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java @@ -30,9 +30,9 @@ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. */ -package com.jogamp.gluegen.test.junit; +package com.jogamp.gluegen.test.junit.generation; -import com.jogamp.gluegen.test.junit.impl.BindingTest1p1Impl; +import com.jogamp.gluegen.test.junit.generation.impl.BindingTest1p1Impl; import com.jogamp.common.nio.Buffers; import com.jogamp.common.nio.PointerBuffer; @@ -52,7 +52,7 @@ import org.junit.BeforeClass; import org.junit.Test; import static java.lang.System.*; -import static com.jogamp.gluegen.test.junit.BuildEnvironment.*; +import static com.jogamp.gluegen.test.junit.generation.BuildEnvironment.*; /** * @author Michael Bien diff --git a/src/junit/com/jogamp/gluegen/test/junit/Test1p2ProcAddressEmitter.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java index 9096eca..83f20d1 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/Test1p2ProcAddressEmitter.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java @@ -30,9 +30,9 @@ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. */ -package com.jogamp.gluegen.test.junit; +package com.jogamp.gluegen.test.junit.generation; -import com.jogamp.gluegen.test.junit.impl.BindingTest1p2Impl; +import com.jogamp.gluegen.test.junit.generation.impl.BindingTest1p2Impl; import com.jogamp.common.nio.Buffers; import com.jogamp.common.nio.PointerBuffer; @@ -54,7 +54,7 @@ import org.junit.BeforeClass; import org.junit.Test; import static java.lang.System.*; -import static com.jogamp.gluegen.test.junit.BuildEnvironment.*; +import static com.jogamp.gluegen.test.junit.generation.BuildEnvironment.*; /** * @author Michael Bien diff --git a/src/junit/com/jogamp/gluegen/test/junit/test1-common.cfg b/src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg index 6ba4b78..6ba4b78 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/test1-common.cfg +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg diff --git a/src/junit/com/jogamp/gluegen/test/junit/test1-gluegen.c b/src/junit/com/jogamp/gluegen/test/junit/generation/test1-gluegen.c index bf6ad97..bf6ad97 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/test1-gluegen.c +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1-gluegen.c diff --git a/src/junit/com/jogamp/gluegen/test/junit/test1-gluegen.cfg b/src/junit/com/jogamp/gluegen/test/junit/generation/test1-gluegen.cfg index 9d0f856..971419e 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/test1-gluegen.cfg +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1-gluegen.cfg @@ -1,4 +1,4 @@ -Package com.jogamp.gluegen.test.junit +Package com.jogamp.gluegen.test.junit.generation JavaClass BindingTest1 Style InterfaceOnly JavaOutputDir classes diff --git a/src/junit/com/jogamp/gluegen/test/junit/test1.c b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c index f654467..f654467 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/test1.c +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c diff --git a/src/junit/com/jogamp/gluegen/test/junit/test1.h b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h index d0e50e5..d0e50e5 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/test1.h +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1p1-gluegen.cfg b/src/junit/com/jogamp/gluegen/test/junit/generation/test1p1-gluegen.cfg new file mode 100644 index 0000000..2062512 --- /dev/null +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1p1-gluegen.cfg @@ -0,0 +1,14 @@ +Package com.jogamp.gluegen.test.junit.generation +JavaClass BindingTest1p1 +Style InterfaceAndImpl +JavaOutputDir classes +NativeOutputDir native + +Extends BindingTest1p1 BindingTest1 + +Include test1-common.cfg + +Import com.jogamp.gluegen.test.junit.generation.BindingTest1 +Import com.jogamp.gluegen.test.junit.generation.BindingTest1p1 + + diff --git a/src/junit/com/jogamp/gluegen/test/junit/test1p2-gluegen.cfg b/src/junit/com/jogamp/gluegen/test/junit/generation/test1p2-gluegen.cfg index 651c93c..e5ace6e 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/test1p2-gluegen.cfg +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1p2-gluegen.cfg @@ -1,4 +1,4 @@ -Package com.jogamp.gluegen.test.junit +Package com.jogamp.gluegen.test.junit.generation JavaClass BindingTest1p2 Style InterfaceAndImpl JavaOutputDir classes @@ -22,10 +22,10 @@ ForceProcAddressGen __ALL__ LocalProcAddressCallingConvention __ALL__ MYAPIENTRY Include test1-common.cfg -Include ../../../../../../../make/config/intptr.cfg +Include ../../../../../../../../make/config/intptr.cfg -Import com.jogamp.gluegen.test.junit.BindingTest1 -Import com.jogamp.gluegen.test.junit.BindingTest1p2 +Import com.jogamp.gluegen.test.junit.generation.BindingTest1 +Import com.jogamp.gluegen.test.junit.generation.BindingTest1p2 CustomJavaCode BindingTest1p2Impl private static BindingTest1p2ProcAddressTable _table = new BindingTest1p2ProcAddressTable(); CustomJavaCode BindingTest1p2Impl public static void resetProcAddressTable(DynamicLookupHelper lookup) { diff --git a/src/junit/com/jogamp/gluegen/test/junit/runtime/TestPointerBufferEndian.java b/src/junit/com/jogamp/gluegen/test/junit/runtime/TestPointerBufferEndian.java new file mode 100644 index 0000000..a57fd22 --- /dev/null +++ b/src/junit/com/jogamp/gluegen/test/junit/runtime/TestPointerBufferEndian.java @@ -0,0 +1,54 @@ + +package com.jogamp.gluegen.test.junit.runtime; + +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.*; + +public class TestPointerBufferEndian { + + protected void testImpl (boolean direct) { + int bitsPtr = Platform.getPointerSizeInBits(); + 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"); + + long[] valuesSource = { 0x0123456789ABCDEFL, 0x8877665544332211L, 0xAFFEDEADBEEFAFFEL }; + long[] values32Bit = { 0x0000000089ABCDEFL, 0x0000000044332211L, 0x00000000BEEFAFFEL }; + + PointerBuffer ptr = direct ? PointerBuffer.allocateDirect(3) : PointerBuffer.allocate(valuesSource.length); + ptr.put(valuesSource, 0, valuesSource.length); + ptr.rewind(); + + int i=0; + while(ptr.hasRemaining()) { + long mask = Platform.is32Bit() ? 0x00000000FFFFFFFFL : 0xFFFFFFFFFFFFFFFFL ; + long v = ptr.get() & mask; + long t = Platform.is32Bit() ? values32Bit[i] : valuesSource[i]; + Assert.assertTrue("Value["+i+"] shall be 0x"+Long.toHexString(t)+", is: 0x"+Long.toHexString(v), t == v); + i++; + } + Assert.assertTrue("iterator "+i+" != "+valuesSource.length, i==valuesSource.length); + } + + @Test + public void testDirect () { + testImpl (true); + } + + @Test + public void testIndirect () { + testImpl (false); + } +} diff --git a/src/junit/com/jogamp/gluegen/test/junit/runtime/TestStructAccessorEndian.java b/src/junit/com/jogamp/gluegen/test/junit/runtime/TestStructAccessorEndian.java new file mode 100644 index 0000000..264c86b --- /dev/null +++ b/src/junit/com/jogamp/gluegen/test/junit/runtime/TestStructAccessorEndian.java @@ -0,0 +1,43 @@ +package com.jogamp.gluegen.test.junit.runtime; + +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.*; + +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"); + 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"); + + 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); + } + } +} diff --git a/src/junit/com/jogamp/gluegen/test/junit/test1p1-gluegen.cfg b/src/junit/com/jogamp/gluegen/test/junit/test1p1-gluegen.cfg deleted file mode 100644 index 78e4d8a..0000000 --- a/src/junit/com/jogamp/gluegen/test/junit/test1p1-gluegen.cfg +++ /dev/null @@ -1,14 +0,0 @@ -Package com.jogamp.gluegen.test.junit -JavaClass BindingTest1p1 -Style InterfaceAndImpl -JavaOutputDir classes -NativeOutputDir native - -Extends BindingTest1p1 BindingTest1 - -Include test1-common.cfg - -Import com.jogamp.gluegen.test.junit.BindingTest1 -Import com.jogamp.gluegen.test.junit.BindingTest1p1 - - |