aboutsummaryrefslogtreecommitdiffstats
path: root/src/junit
diff options
context:
space:
mode:
Diffstat (limited to 'src/junit')
-rw-r--r--src/junit/com/jogamp/common/net/AssetURLConnectionUnregisteredTest.java2
-rw-r--r--src/junit/com/jogamp/common/net/TestUri01.java32
-rw-r--r--src/junit/com/jogamp/common/nio/BuffersTest.java75
-rw-r--r--src/junit/com/jogamp/common/nio/TestByteBufferCopyStream.java31
-rw-r--r--src/junit/com/jogamp/common/nio/TestByteBufferInputStream.java32
-rw-r--r--src/junit/com/jogamp/common/nio/TestByteBufferOutputStream.java7
-rw-r--r--src/junit/com/jogamp/common/util/BitDemoData.java (renamed from src/junit/com/jogamp/common/util/BitstreamData.java)63
-rw-r--r--src/junit/com/jogamp/common/util/CustomDeflate.java115
-rw-r--r--src/junit/com/jogamp/common/util/CustomInflate.java68
-rw-r--r--src/junit/com/jogamp/common/util/TestArrayHashMap01.java186
-rw-r--r--src/junit/com/jogamp/common/util/TestArrayHashSet01.java123
-rw-r--r--src/junit/com/jogamp/common/util/TestBitfield00.java431
-rw-r--r--src/junit/com/jogamp/common/util/TestBitstream00.java2
-rw-r--r--src/junit/com/jogamp/common/util/TestBitstream01.java2
-rw-r--r--src/junit/com/jogamp/common/util/TestBitstream02.java2
-rw-r--r--src/junit/com/jogamp/common/util/TestBitstream03.java2
-rw-r--r--src/junit/com/jogamp/common/util/TestBitstream04.java2
-rw-r--r--src/junit/com/jogamp/common/util/TestIOUtil01.java96
-rw-r--r--src/junit/com/jogamp/common/util/TestPlatform01.java2
-rw-r--r--src/junit/com/jogamp/common/util/TestRunnableTask01.java4
-rw-r--r--src/junit/com/jogamp/common/util/TestVersionSemantics.java46
-rw-r--r--src/junit/com/jogamp/common/util/locks/TestRecursiveLock01.java7
-rw-r--r--src/junit/com/jogamp/common/util/locks/TestRecursiveThreadGroupLock01.java11
-rw-r--r--src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket00.java6
-rw-r--r--src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket01.java3
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java312
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java16
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2LoadJNIAndImplLib.java11
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java19
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1-CustomJavaCode.cfg7
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg17
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1.c57
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1.h172
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1p1-gluegen.cfg2
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1p2-gluegen.cfg2
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/internals/TestType.java85
-rw-r--r--src/junit/com/jogamp/junit/sec/Applet01.java2
-rw-r--r--src/junit/com/jogamp/junit/sec/TestSecIOUtil01.java2
-rw-r--r--src/junit/com/jogamp/junit/util/SingletonJunitCase.java40
-rw-r--r--src/junit/com/jogamp/junit/util/VersionSemanticsUtil.java16
40 files changed, 1976 insertions, 134 deletions
diff --git a/src/junit/com/jogamp/common/net/AssetURLConnectionUnregisteredTest.java b/src/junit/com/jogamp/common/net/AssetURLConnectionUnregisteredTest.java
index 5167abb..1bb88c5 100644
--- a/src/junit/com/jogamp/common/net/AssetURLConnectionUnregisteredTest.java
+++ b/src/junit/com/jogamp/common/net/AssetURLConnectionUnregisteredTest.java
@@ -38,7 +38,7 @@ public class AssetURLConnectionUnregisteredTest extends AssetURLConnectionBase {
@Test
public void assetUnregisteredIOUtilGetResourceRel0_RT() throws IOException, URISyntaxException {
- final URLConnection urlConn0 = IOUtil.getResource(this.getClass(), test_asset_test2_rel.get());
+ final URLConnection urlConn0 = IOUtil.getResource(test_asset_test2_rel.get(), this.getClass().getClassLoader(), this.getClass());
testAssetConnection(urlConn0, test_asset_test2_entry);
final Uri uri1 = Uri.valueOf(urlConn0.getURL()).getRelativeOf(test_asset_test3_rel);
diff --git a/src/junit/com/jogamp/common/net/TestUri01.java b/src/junit/com/jogamp/common/net/TestUri01.java
index 1173610..4205de1 100644
--- a/src/junit/com/jogamp/common/net/TestUri01.java
+++ b/src/junit/com/jogamp/common/net/TestUri01.java
@@ -248,6 +248,20 @@ public class TestUri01 extends SingletonJunitCase {
@Test
public void test08NormalizedHierarchy() throws IOException, URISyntaxException {
{
+ final Uri input = Uri.cast("./dummy/nop/../a.txt");
+ final Uri expected = Uri.cast("dummy/a.txt");
+ URIDumpUtil.showUri(input);
+ final Uri normal = input.getNormalized();
+ Assert.assertEquals(expected, normal);
+ }
+ {
+ final Uri input = Uri.cast("../dummy/nop/../a.txt");
+ final Uri expected = Uri.cast("../dummy/a.txt");
+ URIDumpUtil.showUri(input);
+ final Uri normal = input.getNormalized();
+ Assert.assertEquals(expected, normal);
+ }
+ {
final Uri input = Uri.cast("http://localhost/dummy/../");
final Uri expected = Uri.cast("http://localhost/");
URIDumpUtil.showUri(input);
@@ -255,7 +269,21 @@ public class TestUri01 extends SingletonJunitCase {
Assert.assertEquals(expected, normal);
}
{
- final Uri input = Uri.cast("http://localhost/test/dummy/../text.txt");
+ final Uri input = Uri.cast("http://localhost/dummy/./../");
+ final Uri expected = Uri.cast("http://localhost/");
+ URIDumpUtil.showUri(input);
+ final Uri normal = input.getNormalized();
+ Assert.assertEquals(expected, normal);
+ }
+ {
+ final Uri input = Uri.cast("http://localhost/dummy/../aa/././../");
+ final Uri expected = Uri.cast("http://localhost/");
+ URIDumpUtil.showUri(input);
+ final Uri normal = input.getNormalized();
+ Assert.assertEquals(expected, normal);
+ }
+ {
+ final Uri input = Uri.cast("http://localhost/test/dummy/./../text.txt");
final Uri expected = Uri.cast("http://localhost/test/text.txt");
URIDumpUtil.showUri(input);
final Uri normal = input.getNormalized();
@@ -280,7 +308,7 @@ public class TestUri01 extends SingletonJunitCase {
Assert.assertEquals(expected, normal);
}
{
- final Uri input = Uri.cast("jar:http://localhost/test/dummy/../abc.jar!/");
+ final Uri input = Uri.cast("jar:http://localhost/test/./dummy/../abc.jar!/");
final Uri expected = Uri.cast("jar:http://localhost/test/abc.jar!/");
URIDumpUtil.showUri(input);
final Uri normal = input.getNormalized();
diff --git a/src/junit/com/jogamp/common/nio/BuffersTest.java b/src/junit/com/jogamp/common/nio/BuffersTest.java
index c6a89f1..c267100 100644
--- a/src/junit/com/jogamp/common/nio/BuffersTest.java
+++ b/src/junit/com/jogamp/common/nio/BuffersTest.java
@@ -31,7 +31,15 @@
*/
package com.jogamp.common.nio;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.DoubleBuffer;
+import java.nio.FloatBuffer;
import java.nio.IntBuffer;
+import java.nio.LongBuffer;
+import java.nio.ShortBuffer;
+
import org.junit.Test;
import com.jogamp.junit.util.SingletonJunitCase;
@@ -48,7 +56,66 @@ import org.junit.runners.MethodSorters;
public class BuffersTest extends SingletonJunitCase {
@Test
- public void slice() {
+ public void test01PositionLimitCapacityAfterArrayAllocation() {
+ final byte[] byteData = { 1, 2, 3, 4, 5, 6, 7, 8 };
+ final ByteBuffer byteBuffer = Buffers.newDirectByteBuffer(byteData);
+ assertEquals(0, byteBuffer.position());
+ assertEquals(8, byteBuffer.limit());
+ assertEquals(8, byteBuffer.capacity());
+ assertEquals(8, byteBuffer.remaining());
+ assertEquals(5, byteBuffer.get(4));
+
+ final double[] doubleData = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 };
+ final DoubleBuffer doubleBuffer = Buffers.newDirectDoubleBuffer(doubleData);
+ assertEquals(0, doubleBuffer.position());
+ assertEquals(8, doubleBuffer.limit());
+ assertEquals(8, doubleBuffer.capacity());
+ assertEquals(8, doubleBuffer.remaining());
+ assertEquals(5.0, doubleBuffer.get(4), 0.1);
+
+ final float[] floatData = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
+ final FloatBuffer floatBuffer = Buffers.newDirectFloatBuffer(floatData);
+ assertEquals(0, floatBuffer.position());
+ assertEquals(8, floatBuffer.limit());
+ assertEquals(8, floatBuffer.capacity());
+ assertEquals(8, floatBuffer.remaining());
+ assertEquals(5.0f, floatBuffer.get(4), 0.1f);
+
+ final int[] intData = { 1, 2, 3, 4, 5, 6, 7, 8 };
+ final IntBuffer intBuffer = Buffers.newDirectIntBuffer(intData);
+ assertEquals(0, intBuffer.position());
+ assertEquals(8, intBuffer.limit());
+ assertEquals(8, intBuffer.capacity());
+ assertEquals(8, intBuffer.remaining());
+ assertEquals(5, intBuffer.get(4));
+
+ final long[] longData = { 1, 2, 3, 4, 5, 6, 7, 8 };
+ final LongBuffer longBuffer = Buffers.newDirectLongBuffer(longData);
+ assertEquals(0, longBuffer.position());
+ assertEquals(8, longBuffer.limit());
+ assertEquals(8, longBuffer.capacity());
+ assertEquals(8, longBuffer.remaining());
+ assertEquals(5, longBuffer.get(4));
+
+ final short[] shortData = { 1, 2, 3, 4, 5, 6, 7, 8 };
+ final ShortBuffer shortBuffer = Buffers.newDirectShortBuffer(shortData);
+ assertEquals(0, shortBuffer.position());
+ assertEquals(8, shortBuffer.limit());
+ assertEquals(8, shortBuffer.capacity());
+ assertEquals(8, shortBuffer.remaining());
+ assertEquals(5, shortBuffer.get(4));
+
+ final char[] charData = { 1, 2, 3, 4, 5, 6, 7, 8 };
+ final CharBuffer charBuffer = Buffers.newDirectCharBuffer(charData);
+ assertEquals(0, charBuffer.position());
+ assertEquals(8, charBuffer.limit());
+ assertEquals(8, charBuffer.capacity());
+ assertEquals(8, charBuffer.remaining());
+ assertEquals(5, charBuffer.get(4));
+ }
+
+ @Test
+ public void test10Slice() {
final IntBuffer buffer = Buffers.newDirectIntBuffer(6);
buffer.put(new int[]{1,2,3,4,5,6}).rewind();
@@ -87,8 +154,10 @@ public class BuffersTest extends SingletonJunitCase {
assertEquals(42, buffer.get(2));
assertEquals(42, onetwothree.get(2));
-
-
}
+ public static void main(final String args[]) throws IOException {
+ final String tstname = BuffersTest.class.getName();
+ org.junit.runner.JUnitCore.main(tstname);
+ }
}
diff --git a/src/junit/com/jogamp/common/nio/TestByteBufferCopyStream.java b/src/junit/com/jogamp/common/nio/TestByteBufferCopyStream.java
index bef813b..9524e91 100644
--- a/src/junit/com/jogamp/common/nio/TestByteBufferCopyStream.java
+++ b/src/junit/com/jogamp/common/nio/TestByteBufferCopyStream.java
@@ -35,6 +35,7 @@ import java.nio.channels.FileChannel;
import org.junit.Assert;
import org.junit.Test;
+import com.jogamp.common.os.Platform;
import com.jogamp.junit.util.SingletonJunitCase;
import org.junit.FixMethodOrder;
@@ -171,27 +172,42 @@ public class TestByteBufferCopyStream extends SingletonJunitCase {
@Test
public void test00() throws IOException {
+ final long size;
+ if( !manualTest && Platform.OSType.MACOS == Platform.getOSType() ) {
+ size = quaterGiB;
+ } else {
+ size = twoPlusGiB;
+ }
final int srcSliceShift = MappedByteBufferInputStream.DEFAULT_SLICE_SHIFT;
final int dstSliceShift = MappedByteBufferInputStream.DEFAULT_SLICE_SHIFT;
- final long size = twoPlusGiB;
testImpl(getSimpleTestName(".")+"_In.bin", size, MappedByteBufferInputStream.CacheMode.FLUSH_PRE_HARD, srcSliceShift,
- getSimpleTestName(".")+"_Out.bin", MappedByteBufferInputStream.CacheMode.FLUSH_PRE_HARD, dstSliceShift );
+ getSimpleTestName(".")+"_Out.bin", MappedByteBufferInputStream.CacheMode.FLUSH_PRE_HARD, dstSliceShift );
}
@Test
public void test01() throws IOException {
+ final long size;
+ if( !manualTest && Platform.OSType.MACOS == Platform.getOSType() ) {
+ size = quaterGiB;
+ } else {
+ size = twoPlusGiB;
+ }
final int srcSliceShift = MappedByteBufferInputStream.DEFAULT_SLICE_SHIFT;
final int dstSliceShift = MappedByteBufferInputStream.DEFAULT_SLICE_SHIFT;
- final long size = twoPlusGiB;
testImpl(getSimpleTestName(".")+"_In.bin", size, MappedByteBufferInputStream.CacheMode.FLUSH_PRE_SOFT, srcSliceShift,
getSimpleTestName(".")+"_Out.bin", MappedByteBufferInputStream.CacheMode.FLUSH_PRE_SOFT, dstSliceShift );
}
@Test
public void test02() throws IOException {
+ final long size;
+ if( !manualTest && Platform.OSType.MACOS == Platform.getOSType() ) {
+ size = quaterPlusGiB;
+ } else {
+ size = halfPlusGiB;
+ }
final int srcSliceShift = 27; // 125M bytes per slice
final int dstSliceShift = 27; // 125M bytes per slice
- final long size = halfPlusGiB;
testImpl(getSimpleTestName(".")+"_In.bin", size, MappedByteBufferInputStream.CacheMode.FLUSH_PRE_SOFT, srcSliceShift,
getSimpleTestName(".")+"_Out.bin", MappedByteBufferInputStream.CacheMode.FLUSH_PRE_SOFT, dstSliceShift );
}
@@ -214,7 +230,14 @@ public class TestByteBufferCopyStream extends SingletonJunitCase {
getSimpleTestName(".")+"_Out.bin", MappedByteBufferInputStream.CacheMode.FLUSH_PRE_SOFT, dstSliceShift );
}
+ static boolean manualTest = false;
+
public static void main(final String args[]) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-manual")) {
+ manualTest = true;
+ }
+ }
final String tstname = TestByteBufferCopyStream.class.getName();
org.junit.runner.JUnitCore.main(tstname);
}
diff --git a/src/junit/com/jogamp/common/nio/TestByteBufferInputStream.java b/src/junit/com/jogamp/common/nio/TestByteBufferInputStream.java
index 53ebac9..90a954b 100644
--- a/src/junit/com/jogamp/common/nio/TestByteBufferInputStream.java
+++ b/src/junit/com/jogamp/common/nio/TestByteBufferInputStream.java
@@ -41,6 +41,7 @@ import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
+import com.jogamp.common.os.Platform;
import com.jogamp.common.util.IOUtil;
import com.jogamp.junit.util.SingletonJunitCase;
@@ -144,20 +145,32 @@ public class TestByteBufferInputStream extends SingletonJunitCase {
@Test
public void test11MMap1GiBFlushNone() throws IOException {
- testCopyIntSize1Impl2(0, SrcType.MMAP2_NONE, 0, fileOneGiB, oneGiB);
- // testCopyIntSize1Impl2(0, SrcType.MMAP2_NONE, 0, fileTwoPlusGiB, twoPlusGiB);
+ if( !manualTest && Platform.OSType.MACOS == Platform.getOSType() ) {
+ testCopyIntSize1Impl2(0, SrcType.MMAP2_NONE, 0, fileOneMiB, oneMiB);
+ } else {
+ testCopyIntSize1Impl2(0, SrcType.MMAP2_NONE, 0, fileOneGiB, oneGiB);
+ // testCopyIntSize1Impl2(0, SrcType.MMAP2_NONE, 0, fileTwoPlusGiB, twoPlusGiB);
+ }
}
@Test
public void test12MMap1GiBFlushSoft() throws IOException {
- testCopyIntSize1Impl2(0, SrcType.MMAP2_SOFT, 0, fileOneGiB, oneGiB);
- // testCopyIntSize1Impl2(0, SrcType.MMAP2_SOFT, 0, fileTwoPlusGiB, twoPlusGiB);
+ if( !manualTest && Platform.OSType.MACOS == Platform.getOSType() ) {
+ testCopyIntSize1Impl2(0, SrcType.MMAP2_SOFT, 0, fileOneMiB, oneMiB);
+ } else {
+ testCopyIntSize1Impl2(0, SrcType.MMAP2_SOFT, 0, fileOneGiB, oneGiB);
+ // testCopyIntSize1Impl2(0, SrcType.MMAP2_SOFT, 0, fileTwoPlusGiB, twoPlusGiB);
+ }
}
@Test
public void test13MMap2GiBFlushHard() throws IOException {
- // testCopyIntSize1Impl2(0, SrcType.MMAP2_HARD, 0, fileOneGiB, oneGiB);
- testCopyIntSize1Impl2(0, SrcType.MMAP2_HARD, 0, fileTwoPlusGiB, twoPlusGiB);
+ if( !manualTest && Platform.OSType.MACOS == Platform.getOSType() ) {
+ testCopyIntSize1Impl2(0, SrcType.MMAP2_HARD, 0, fileOneMiB, oneMiB);
+ } else {
+ // testCopyIntSize1Impl2(0, SrcType.MMAP2_HARD, 0, fileOneGiB, oneGiB);
+ testCopyIntSize1Impl2(0, SrcType.MMAP2_HARD, 0, fileTwoPlusGiB, twoPlusGiB);
+ }
}
void testCopyIntSize1Impl(final String testFileName, final long expSize) throws IOException {
@@ -336,7 +349,14 @@ public class TestByteBufferInputStream extends SingletonJunitCase {
System.err.println(" MiB"); */
}
+ static boolean manualTest = false;
+
public static void main(final String args[]) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-manual")) {
+ manualTest = true;
+ }
+ }
final String tstname = TestByteBufferInputStream.class.getName();
org.junit.runner.JUnitCore.main(tstname);
}
diff --git a/src/junit/com/jogamp/common/nio/TestByteBufferOutputStream.java b/src/junit/com/jogamp/common/nio/TestByteBufferOutputStream.java
index 8686b46..b0d7baf 100644
--- a/src/junit/com/jogamp/common/nio/TestByteBufferOutputStream.java
+++ b/src/junit/com/jogamp/common/nio/TestByteBufferOutputStream.java
@@ -284,7 +284,14 @@ public class TestByteBufferOutputStream extends SingletonJunitCase {
testImpl(getSimpleTestName(".")+".bin", payLoad, 3021L, 6301L, "EOF".getBytes(), sliceShift);
}
+ static boolean manualTest = false;
+
public static void main(final String args[]) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-manual")) {
+ manualTest = true;
+ }
+ }
final String tstname = TestByteBufferOutputStream.class.getName();
org.junit.runner.JUnitCore.main(tstname);
}
diff --git a/src/junit/com/jogamp/common/util/BitstreamData.java b/src/junit/com/jogamp/common/util/BitDemoData.java
index a5a0bd9..9d605fc 100644
--- a/src/junit/com/jogamp/common/util/BitstreamData.java
+++ b/src/junit/com/jogamp/common/util/BitDemoData.java
@@ -30,11 +30,49 @@ package com.jogamp.common.util;
import java.nio.ByteBuffer;
-public class BitstreamData {
+public class BitDemoData {
+ public static final long UNSIGNED_INT_MAX_VALUE = 0xffffffffL;
+
+ public static final String[] pyramid32bit_one = {
+ "00000000000000000000000000000001",
+ "00000000000000000000000000000010",
+ "00000000000000000000000000000100",
+ "00000000000000000000000000001000",
+ "00000000000000000000000000010000",
+ "00000000000000000000000000100000",
+ "00000000000000000000000001000000",
+ "00000000000000000000000010000000",
+ "00000000000000000000000100000000",
+ "00000000000000000000001000000000",
+ "00000000000000000000010000000000",
+ "00000000000000000000100000000000",
+ "00000000000000000001000000000000",
+ "00000000000000000010000000000000",
+ "00000000000000000100000000000000",
+ "00000000000000001000000000000000",
+ "00000000000000010000000000000000",
+ "00000000000000100000000000000000",
+ "00000000000001000000000000000000",
+ "00000000000010000000000000000000",
+ "00000000000100000000000000000000",
+ "00000000001000000000000000000000",
+ "00000000010000000000000000000000",
+ "00000000100000000000000000000000",
+ "00000001000000000000000000000000",
+ "00000010000000000000000000000000",
+ "00000100000000000000000000000000",
+ "00001000000000000000000000000000",
+ "00010000000000000000000000000000",
+ "00100000000000000000000000000000",
+ "01000000000000000000000000000000",
+ "10000000000000000000000000000000"
+ };
+
//
// MSB -> LSB over whole data
//
public static final byte[] testBytesMSB = new byte[] { (byte)0xde, (byte)0xaf, (byte)0xca, (byte)0xfe };
+ public static final int testIntMSB = 0xdeafcafe; // 11011110 10101111 11001010 11111110
public static final String[] testStringsMSB = new String[] { "11011110", "10101111", "11001010", "11111110" };
public static final String testStringMSB = testStringsMSB[0]+testStringsMSB[1]+testStringsMSB[2]+testStringsMSB[3];
@@ -42,6 +80,7 @@ public class BitstreamData {
// MSB -> LSB, reverse bit-order over each byte of testBytesLSB
//
public static final byte[] testBytesMSB_rev = new byte[] { (byte)0xfe, (byte)0xca, (byte)0xaf, (byte)0xde };
+ public static final int testIntMSB_rev = 0xfecaafde;
public static final String[] testStringsMSB_rev = new String[] { "11111110", "11001010", "10101111", "11011110" };
public static final String testStringMSB_rev = testStringsMSB_rev[0]+testStringsMSB_rev[1]+testStringsMSB_rev[2]+testStringsMSB_rev[3];
@@ -49,6 +88,7 @@ public class BitstreamData {
// LSB -> MSB over whole data
//
public static final byte[] testBytesLSB = new byte[] { (byte)0x7f, (byte)0x53, (byte)0xf5, (byte)0x7b };
+ public static final int testIntLSB = 0x7f53f57b;
public static final String[] testStringsLSB = new String[] { "01111111", "01010011", "11110101", "01111011" };
public static final String testStringLSB = testStringsLSB[0]+testStringsLSB[1]+testStringsLSB[2]+testStringsLSB[3];
@@ -56,6 +96,7 @@ public class BitstreamData {
// LSB -> MSB, reverse bit-order over each byte of testBytesMSB
//
public static final byte[] testBytesLSB_revByte = new byte[] { (byte)0x7b, (byte)0xf5, (byte)0x53, (byte)0x7f };
+ public static final int testIntLSB_revByte = 0x7bf5537f;
public static final String[] testStringsLSB_revByte = new String[] { "01111011", "11110101", "01010011", "01111111" };
public static final String testStringLSB_revByte = testStringsLSB_revByte[0]+testStringsLSB_revByte[1]+testStringsLSB_revByte[2]+testStringsLSB_revByte[3];
@@ -80,6 +121,26 @@ public class BitstreamData {
}
}
+ public static int getOneBitCount(final String pattern) {
+ int c=0;
+ for(int i=0; i<pattern.length(); i++) {
+ if( '1' == pattern.charAt(i) ) {
+ c++;
+ }
+ }
+ return c;
+ }
+ public static long toLong(final String bitPattern) {
+ return Long.valueOf(bitPattern, 2).longValue();
+ }
+ public static int toInteger(final String bitPattern) {
+ final long res = Long.valueOf(bitPattern, 2).longValue();
+ if( res > UNSIGNED_INT_MAX_VALUE ) {
+ throw new NumberFormatException("Exceeds "+toHexString(UNSIGNED_INT_MAX_VALUE)+": "+toHexString(res)+" - source "+bitPattern);
+ }
+ return (int)res;
+ }
+
public static String toHexString(final int v) {
return "0x"+Integer.toHexString(v);
}
diff --git a/src/junit/com/jogamp/common/util/CustomDeflate.java b/src/junit/com/jogamp/common/util/CustomDeflate.java
new file mode 100644
index 0000000..d4682e8
--- /dev/null
+++ b/src/junit/com/jogamp/common/util/CustomDeflate.java
@@ -0,0 +1,115 @@
+/**
+ * Copyright 2015 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.common.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public class CustomDeflate {
+ public static void main(final String[] args) {
+ if (args.length != 2) {
+ System.err.println("Usage: java "+CustomDeflate.class.getName()+" file-in file-out");
+ } else {
+ final File fileIn = new File(args[0]);
+ final File fileOut = new File(args[1]);
+ final int inSize;
+ {
+ final long _inSize = fileIn.length();
+ if( 0 >= _inSize || _inSize > Integer.MAX_VALUE ) {
+ throw new IllegalArgumentException("");
+ }
+ inSize = (int) _inSize;
+ }
+ final byte[] input = new byte[inSize];
+ InputStream in = null;
+ OutputStream out = null;
+ try {
+ in = new FileInputStream(fileIn);
+ int numBytes = 0;
+ try {
+ while (true) {
+ final int remBytes = inSize - numBytes;
+ int count;
+ if ( 0 >= remBytes || (count = in.read(input, numBytes, remBytes)) == -1 ) {
+ break;
+ }
+ numBytes += count;
+ }
+ } finally {
+ in.close();
+ }
+ if( inSize != numBytes ) {
+ throw new IOException("Got "+numBytes+" bytes != expected "+inSize);
+ }
+ out = new FileOutputStream(fileOut);
+ CustomCompress.deflateToStream(input, 0, inSize, 9, out);
+ } catch (final IOException ioe) {
+ ioe.printStackTrace();
+ } finally {
+ if( null != in ) {
+ try { in.close(); } catch (final IOException e) { }
+ }
+ if( null != out ) {
+ try { out.close(); } catch (final IOException e) { }
+ }
+ }
+
+ //
+ // Test
+ //
+ in = null;
+ out = null;
+ try {
+ in = new FileInputStream(fileOut);
+ final byte[] compare = CustomCompress.inflateFromStream(in);
+ if( compare.length != inSize ) {
+ throw new InternalError("Inflated Size Mismatch: Has "+compare.length+", expected "+inSize);
+ }
+ for(int i=0; i<inSize; i++) {
+ if( input[i] != compare[i] ) {
+ throw new InternalError("Inflated Bytes Mismatch at "+i+"/"+inSize+": Has "+Integer.toHexString(compare[i])+", expected "+Integer.toHexString(input[i]));
+ }
+ }
+ } catch (final IOException ioe) {
+ ioe.printStackTrace();
+ } finally {
+ if( null != in ) {
+ try { in.close(); } catch (final IOException e) { }
+ }
+ if( null != out ) {
+ try { out.close(); } catch (final IOException e) { }
+ }
+ }
+ }
+ }
+
+}
diff --git a/src/junit/com/jogamp/common/util/CustomInflate.java b/src/junit/com/jogamp/common/util/CustomInflate.java
new file mode 100644
index 0000000..477439e
--- /dev/null
+++ b/src/junit/com/jogamp/common/util/CustomInflate.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright 2015 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.common.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public class CustomInflate {
+ public static final int magic = 0xDEF1A7E0;
+
+ public static void main(final String[] args) {
+ if (args.length != 2) {
+ System.err.println("Usage: java "+CustomCompress.class.getName()+" file-in file-out");
+ } else {
+ InputStream in = null;
+ OutputStream out = null;
+ try {
+ final File fileIn = new File(args[0]);
+ in = new FileInputStream(fileIn);
+
+ final byte[] output = CustomCompress.inflateFromStream(in);
+
+ final File fileOut = new File(args[1]);
+ out = new FileOutputStream(fileOut);
+ out.write(output, 0, output.length);
+ out.flush();
+ } catch (final IOException ioe) {
+ ioe.printStackTrace();
+ } finally {
+ if( null != in ) {
+ try { in.close(); } catch (final IOException e) { }
+ }
+ if( null != out ) {
+ try { out.close(); } catch (final IOException e) { }
+ }
+ }
+ }
+ }
+}
diff --git a/src/junit/com/jogamp/common/util/TestArrayHashMap01.java b/src/junit/com/jogamp/common/util/TestArrayHashMap01.java
new file mode 100644
index 0000000..529612c
--- /dev/null
+++ b/src/junit/com/jogamp/common/util/TestArrayHashMap01.java
@@ -0,0 +1,186 @@
+/**
+ * Copyright 2015 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.common.util;
+
+import java.util.*;
+import java.io.IOException;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.jogamp.junit.util.SingletonJunitCase;
+
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestArrayHashMap01 extends SingletonJunitCase {
+
+ public static class Dummy {
+ int i1, i2, i3;
+
+ public Dummy(final int i1, final int i2, final int i3) {
+ this.i1 = i1;
+ this.i2 = i2;
+ this.i3 = i3;
+ }
+
+ public boolean equals(final Object o) {
+ if(o instanceof Dummy) {
+ final Dummy d = (Dummy)o;
+ return this.i1 == d.i1 &&
+ this.i2 == d.i2 &&
+ this.i3 == d.i3 ;
+ }
+ return false;
+ }
+
+ public final int hashCode() {
+ // 31 * x == (x << 5) - x
+ int hash = 31 + i1;
+ hash = ((hash << 5) - hash) + i2;
+ hash = ((hash << 5) - hash) + i3;
+ return hash;
+ }
+
+ public String toString() {
+ return "Dummy["+super.toString()+": "+i1+", "+i2+", "+i3+"]";
+ }
+ }
+
+ void populate(final Map<Integer, Dummy> l, final int start, final int len,
+ final int i2, final int i3, final int expectedPlusSize) {
+ final int oldSize = l.size();
+ for(int pos = start+len-1; pos>=start; pos--) {
+ l.put(pos, new Dummy(pos, i2, i3));
+ }
+ Assert.assertEquals(expectedPlusSize, l.size() - oldSize);
+ }
+ boolean checkOrder(final List<Dummy> l, final int startIdx, final int start, final int len) {
+ for(int i=0; i<len; i++) {
+ final Dummy d = l.get(startIdx+i);
+ final int i1 = start+len-1-i;
+ if( d.i1 != i1 ) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Test
+ public void test01ArrayHashMapWithNullValue() {
+ testArrayHashMapImpl(true);
+ }
+ @Test
+ public void test02ArrayHashSetWithoutNullValue() {
+ testArrayHashMapImpl(false);
+ }
+ void testArrayHashMapImpl(final boolean supportNullValue) {
+ final ArrayHashMap<Integer, Dummy> l =
+ new ArrayHashMap<Integer, Dummy>(supportNullValue,
+ ArrayHashSet.DEFAULT_INITIAL_CAPACITY,
+ ArrayHashSet.DEFAULT_LOAD_FACTOR);
+ Assert.assertEquals(supportNullValue, l.supportsNullValue());
+ final int p7_22_34_key, p7_22_34_idx;
+ final Dummy p7_22_34_orig;
+ final int p6_22_34_key, p6_22_34_idx;
+ final Dummy p6_22_34_orig;
+ {
+ populate(l, 10, 100, 22, 34, 100); // [109 .. 10]
+ Assert.assertTrue(checkOrder(l.getData(), 0, 10, 100));
+ populate(l, 10, 100, 22, 34, 0); // [109 .. 10]
+ Assert.assertTrue(checkOrder(l.getData(), 0, 10, 100));
+ populate(l, 6, 5, 22, 34, 4); // [ 9 .. 6], 10 already exists
+ Assert.assertTrue(checkOrder(l.getData(), 100, 6, 4));
+ p7_22_34_idx = l.size() - 2;
+ p7_22_34_key = 7;
+ p7_22_34_orig = l.get(p7_22_34_key);
+ p6_22_34_idx = l.size() - 1;
+ p6_22_34_key = 6;
+ p6_22_34_orig = l.get(p6_22_34_key);
+ }
+ Assert.assertNotNull(p7_22_34_orig);
+ Assert.assertEquals(7, p7_22_34_orig.i1);
+ Assert.assertEquals(l.getData().get(p7_22_34_idx), p7_22_34_orig);
+ Assert.assertNotNull(p6_22_34_orig);
+ Assert.assertEquals(6, p6_22_34_orig.i1);
+ Assert.assertEquals(l.getData().get(p6_22_34_idx), p6_22_34_orig);
+
+ final Dummy p7_22_34_other = new Dummy(7, 22, 34);
+ Assert.assertEquals(p7_22_34_other, p7_22_34_orig);
+ Assert.assertTrue(p7_22_34_other.hashCode() == p7_22_34_orig.hashCode());
+ Assert.assertTrue(p7_22_34_other != p7_22_34_orig); // diff reference
+ final Dummy p6_22_34_other = new Dummy(6, 22, 34);
+ Assert.assertEquals(p6_22_34_other, p6_22_34_orig);
+ Assert.assertTrue(p6_22_34_other.hashCode() == p6_22_34_orig.hashCode());
+ Assert.assertTrue(p6_22_34_other != p6_22_34_orig); // diff reference
+
+ // fast identity ..
+ Dummy q = l.get(p6_22_34_key);
+ Assert.assertNotNull(q);
+ Assert.assertEquals(p6_22_34_other, q);
+ Assert.assertTrue(p6_22_34_other.hashCode() == q.hashCode());
+ Assert.assertTrue(p6_22_34_other != q); // diff reference
+ Assert.assertTrue(p6_22_34_orig == q); // same reference
+
+ Assert.assertTrue(l.containsValue(q));
+ Assert.assertTrue(l.containsValue(p6_22_34_other)); // add equivalent
+
+ q = l.put(p6_22_34_key, p6_22_34_other); // override w/ diff hash-obj
+ Assert.assertNotNull(q);
+ Assert.assertEquals(p6_22_34_other, q);
+ Assert.assertTrue(p6_22_34_other.hashCode() == q.hashCode());
+ Assert.assertTrue(p6_22_34_other != q); // diff reference new != old (q)
+ Assert.assertTrue(p6_22_34_orig == q); // same reference orig == old (q)
+ Assert.assertTrue(checkOrder(l.getData(), 0, 10, 100));
+ Assert.assertTrue(checkOrder(l.getData(), 100, 6, 4));
+
+ final Dummy p1_2_3 = new Dummy(1, 2, 3); // a new one ..
+ q = l.put(1, p1_2_3); // added test
+ Assert.assertNull(q);
+
+ final Dummy pNull = null;
+ NullPointerException npe = null;
+ try {
+ q = l.put(0, pNull);
+ Assert.assertNull(q);
+ } catch (final NullPointerException _npe) { npe = _npe; }
+ if( l.supportsNullValue() ) {
+ Assert.assertNull(npe);
+ } else {
+ Assert.assertNotNull(npe);
+ }
+ }
+
+ public static void main(final String args[]) throws IOException {
+ final String tstname = TestArrayHashMap01.class.getName();
+ org.junit.runner.JUnitCore.main(tstname);
+ }
+
+}
diff --git a/src/junit/com/jogamp/common/util/TestArrayHashSet01.java b/src/junit/com/jogamp/common/util/TestArrayHashSet01.java
index 51db2c7..3e8fbc0 100644
--- a/src/junit/com/jogamp/common/util/TestArrayHashSet01.java
+++ b/src/junit/com/jogamp/common/util/TestArrayHashSet01.java
@@ -74,47 +74,99 @@ public class TestArrayHashSet01 extends SingletonJunitCase {
}
}
- public void populate(final List<Dummy> l, final int start, final int len, final int i2, final int i3, final int expectedPlusSize) {
+ void populate(final List<Dummy> l, final int start, final int len,
+ final int i2, final int i3, final int expectedPlusSize) {
final int oldSize = l.size();
- int pos = start+len-1;
- while(pos>=start) {
- l.add(new Dummy(pos--, i2, i3));
+ for(int pos = start+len-1; pos>=start; pos--) {
+ l.add(new Dummy(pos, i2, i3));
}
Assert.assertEquals(expectedPlusSize, l.size() - oldSize);
}
+ boolean checkOrder(final List<Dummy> l, final int startIdx, final int start, final int len) {
+ for(int i=0; i<len; i++) {
+ final Dummy d = l.get(startIdx+i);
+ final int i1 = start+len-1-i;
+ if( d.i1 != i1 ) {
+ return false;
+ }
+ }
+ return true;
+ }
@Test
- public void test01ArrayHashSet() {
- final ArrayHashSet<Dummy> l = new ArrayHashSet<Dummy>();
- populate(l, 10, 100, 22, 34, 100); // [10 .. 109]
- populate(l, 10, 100, 22, 34, 0); // [10 .. 109]
- populate(l, 6, 5, 22, 34, 4); // [ 6 .. 9], 10 already exists
-
- final Dummy p6_22_34 = new Dummy(6, 22, 34);
+ public void test01ArrayHashSetWithNullValue() {
+ testArrayHashSetImpl(true);
+ }
+ @Test
+ public void test02ArrayHashSetWithoutNullValue() {
+ testArrayHashSetImpl(false);
+ }
+ void testArrayHashSetImpl(final boolean supportNullValue) {
+ final ArrayHashSet<Dummy> l =
+ new ArrayHashSet<Dummy>(supportNullValue,
+ ArrayHashSet.DEFAULT_INITIAL_CAPACITY,
+ ArrayHashSet.DEFAULT_LOAD_FACTOR);
+ Assert.assertEquals(supportNullValue, l.supportsNullValue());
+ final int p7_22_34_idx;
+ final Dummy p7_22_34_orig;
+ final int p6_22_34_idx;
+ final Dummy p6_22_34_orig;
+ {
+ populate(l, 10, 100, 22, 34, 100); // [109 .. 10]
+ Assert.assertTrue(checkOrder(l, 0, 10, 100));
+ populate(l, 10, 100, 22, 34, 0); // [109 .. 10]
+ Assert.assertTrue(checkOrder(l, 0, 10, 100));
+ populate(l, 6, 5, 22, 34, 4); // [ 9 .. 6], 10 already exists
+ Assert.assertTrue(checkOrder(l, 100, 6, 4));
+ p7_22_34_idx = l.size() - 2;
+ p7_22_34_orig = l.get(p7_22_34_idx);
+ p6_22_34_idx = l.size() - 1;
+ p6_22_34_orig = l.get(p6_22_34_idx);
+ }
+ Assert.assertNotNull(p7_22_34_orig);
+ Assert.assertEquals(7, p7_22_34_orig.i1);
+ Assert.assertEquals(l.getData().get(p7_22_34_idx), p7_22_34_orig);
+ Assert.assertNotNull(p6_22_34_orig);
+ Assert.assertEquals(6, p6_22_34_orig.i1);
+ Assert.assertEquals(l.getData().get(p6_22_34_idx), p6_22_34_orig);
+
+ final Dummy p7_22_34_other = new Dummy(7, 22, 34);
+ Assert.assertEquals(p7_22_34_other, p7_22_34_orig);
+ Assert.assertTrue(p7_22_34_other.hashCode() == p7_22_34_orig.hashCode());
+ Assert.assertTrue(p7_22_34_other != p7_22_34_orig); // diff reference
+ final Dummy p6_22_34_other = new Dummy(6, 22, 34);
+ Assert.assertEquals(p6_22_34_other, p6_22_34_orig);
+ Assert.assertTrue(p6_22_34_other.hashCode() == p6_22_34_orig.hashCode());
+ Assert.assertTrue(p6_22_34_other != p6_22_34_orig); // diff reference
// slow get on position ..
- final int i = l.indexOf(p6_22_34);
+ final int i = l.indexOf(p6_22_34_other);
Dummy q = l.get(i);
Assert.assertNotNull(q);
- Assert.assertEquals(p6_22_34, q);
- Assert.assertTrue(p6_22_34.hashCode() == q.hashCode());
- Assert.assertTrue(p6_22_34 != q); // diff reference
+ Assert.assertEquals(p6_22_34_other, q);
+ Assert.assertTrue(p6_22_34_other.hashCode() == q.hashCode());
+ Assert.assertTrue(p6_22_34_other != q); // diff reference
+ Assert.assertTrue(p6_22_34_orig == q); // same reference
// fast identity ..
- q = l.get(p6_22_34);
+ q = l.get(p6_22_34_other);
Assert.assertNotNull(q);
- Assert.assertEquals(p6_22_34, q);
- Assert.assertTrue(p6_22_34.hashCode() == q.hashCode());
- Assert.assertTrue(p6_22_34 != q); // diff reference
+ Assert.assertEquals(p6_22_34_other, q);
+ Assert.assertTrue(p6_22_34_other.hashCode() == q.hashCode());
+ Assert.assertTrue(p6_22_34_other != q); // diff reference
+ Assert.assertTrue(p6_22_34_orig == q); // same reference
Assert.assertTrue(!l.add(q)); // add same
- Assert.assertTrue(!l.add(p6_22_34)); // add equivalent
+ Assert.assertTrue(!l.add(p6_22_34_other)); // add equivalent
- q = l.getOrAdd(p6_22_34); // not added test
+ q = l.getOrAdd(p6_22_34_other); // not added test w/ diff hash-obj
Assert.assertNotNull(q);
- Assert.assertEquals(p6_22_34, q);
- Assert.assertTrue(p6_22_34.hashCode() == q.hashCode());
- Assert.assertTrue(p6_22_34 != q); // diff reference
+ Assert.assertEquals(p6_22_34_other, q);
+ Assert.assertTrue(p6_22_34_other.hashCode() == q.hashCode());
+ Assert.assertTrue(p6_22_34_other != q); // diff reference
+ Assert.assertTrue(p6_22_34_orig == q); // same reference
+ Assert.assertTrue(checkOrder(l, 0, 10, 100));
+ Assert.assertTrue(checkOrder(l, 100, 6, 4));
final Dummy p1_2_3 = new Dummy(1, 2, 3); // a new one ..
q = l.getOrAdd(p1_2_3); // added test
@@ -122,6 +174,29 @@ public class TestArrayHashSet01 extends SingletonJunitCase {
Assert.assertEquals(p1_2_3, q);
Assert.assertTrue(p1_2_3.hashCode() == q.hashCode());
Assert.assertTrue(p1_2_3 == q); // _same_ reference, since getOrAdd added it
+ Assert.assertTrue(checkOrder(l, 0, 10, 100));
+ Assert.assertTrue(checkOrder(l, 100, 6, 4));
+
+ final Dummy pNull = null;
+ NullPointerException npe = null;
+ try {
+ q = l.getOrAdd(pNull);
+ Assert.assertNull(q);
+ } catch (final NullPointerException _npe) { npe = _npe; }
+ if( l.supportsNullValue() ) {
+ Assert.assertNull(npe);
+ } else {
+ Assert.assertNotNull(npe);
+ }
+
+ try {
+ Assert.assertTrue(l.remove(pNull));
+ } catch (final NullPointerException _npe) { npe = _npe; }
+ if( l.supportsNullValue() ) {
+ Assert.assertNull(npe);
+ } else {
+ Assert.assertNotNull(npe);
+ }
}
public static void main(final String args[]) throws IOException {
diff --git a/src/junit/com/jogamp/common/util/TestBitfield00.java b/src/junit/com/jogamp/common/util/TestBitfield00.java
new file mode 100644
index 0000000..9ace743
--- /dev/null
+++ b/src/junit/com/jogamp/common/util/TestBitfield00.java
@@ -0,0 +1,431 @@
+/**
+ * Copyright 2015 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.common.util;
+
+import java.io.IOException;
+
+import org.junit.Test;
+import org.junit.Assert;
+
+import com.jogamp.junit.util.SingletonJunitCase;
+
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+
+/**
+ * Test basic bitfield operations for {@link Bitfield}
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestBitfield00 extends SingletonJunitCase {
+
+ @Test
+ public void test01_BitCount32_One() {
+ final String[] pyramid32bit_one = BitDemoData.pyramid32bit_one;
+ for(int i=0; i<pyramid32bit_one.length; i++) {
+ final int val0 = 1 << i;
+ final int oneBitCountI = Integer.bitCount(val0);
+ final String pattern0 = pyramid32bit_one[i];
+ final int val1 = BitDemoData.toInteger(pattern0);
+ final String pattern1 = BitDemoData.toBinaryString(val0, 32);
+ final int oneBitCount0 = BitDemoData.getOneBitCount(pattern0);
+ final int oneBitCount1 = Bitfield.Util.bitCount(val0);
+ final String msg = String.format("Round %02d: 0x%08x %s, c %d / %d%n : 0x%08x %s, c %d%n",
+ i, val0, pattern0, oneBitCount0, oneBitCountI, val1, pattern1, oneBitCount1);
+
+ Assert.assertEquals(msg, val0, val1);
+ Assert.assertEquals(msg, pattern0, pattern1);
+
+ Assert.assertEquals(msg, oneBitCount0, oneBitCountI);
+ Assert.assertEquals(msg, oneBitCount0, oneBitCount1);
+ }
+ }
+
+ @SuppressWarnings("unused")
+ @Test
+ public void test02_BitCount32_Samples() {
+ final long MAX = BitDemoData.UNSIGNED_INT_MAX_VALUE;
+ final long MAX_minus = MAX-0x1FF;
+ final long MAX_half = MAX/2;
+ final long MAX_half_minus = MAX_half-0x1FF;
+ final long MAX_half_plus = MAX_half+0x1FF;
+
+ if( false ) {
+ for(long l=0; l<=MAX; l++) {
+ test_BitCount32_Samples(l);
+ }
+ }
+ for(long l=0; l>=0x1FF; l++) {
+ test_BitCount32_Samples(l);
+ }
+ for(long l=MAX_half_minus; l<=MAX_half_plus; l++) {
+ test_BitCount32_Samples(l);
+ }
+ for(long l=MAX_minus; l<=MAX; l++) {
+ test_BitCount32_Samples(l);
+ }
+ }
+ static void test_BitCount32_Samples(final long l) {
+ final int oneBitCountL = Long.bitCount(l);
+ final int val0 = (int)l;
+ final int oneBitCountI = Integer.bitCount(val0);
+ final int oneBitCount1 = Bitfield.Util.bitCount(val0);
+ final String msg = String.format("Round 0x%08x, c %d / %d / %d", val0,
+ oneBitCountL, oneBitCountI, oneBitCount1);
+ Assert.assertEquals(msg, oneBitCountI, oneBitCountL);
+ Assert.assertEquals(msg, oneBitCountI, oneBitCount1);
+ }
+
+ static int[] testDataOneBit = new int[] {
+ 0,0, 1,1, 2,1, 3,2, 4,1, 5,2, 6,2, 7,3,
+ 8,1, 9,2, 10,2, 11,3, 12,2, 13,3, 14,3, 15,4, 16,1, 17,2,
+ 0x3F,6, 0x40,1, 0x41,2, 0x7f,7, 0x80,1, 0x81,2, 0xfe,7, 0xff,8,
+ 0x4000,1, 0x4001,2, 0x7000,3, 0x7fff,15,
+ 0x0FFFFFF0,24,
+ 0x55555555,16,
+ 0x7F53F57B,23, 0xFEA7EAF6,23, /* << 1 */
+ 0x80000000, 1,
+ 0xAAAAAAAA,16,
+ 0xC0C0C0C0, 8,
+ 0xFF000000, 8,
+ 0xFFFFFFFF,32
+ };
+ @Test
+ public void test03_BitCount32_Data() {
+ for(int i = 0; i<testDataOneBit.length; i+=2) {
+ test_BitCount32_Data(testDataOneBit[i], testDataOneBit[i+1]);
+ }
+ }
+ static void test_BitCount32_Data(final int i, final int expOneBits) {
+ final int oneBitCountI = Integer.bitCount(i);
+ final int oneBitCount1 = Bitfield.Util.bitCount(i);
+ final String msg = String.format("Round 0x%08x, c %d / %d", i,
+ oneBitCountI, oneBitCount1);
+ Assert.assertEquals(msg, oneBitCount1, expOneBits);
+ Assert.assertEquals(msg, oneBitCountI, oneBitCount1);
+ }
+
+ @Test
+ public void test10_Setup() {
+ final int bitSize32 = 32;
+ final int bitSize128 = 128;
+ final Bitfield bf1 = Bitfield.Factory.create(bitSize32);
+ Assert.assertEquals(bitSize32, bf1.size());
+ Assert.assertTrue(bf1 instanceof jogamp.common.util.Int32Bitfield);
+ final Bitfield bf2 = Bitfield.Factory.create(bitSize128);
+ Assert.assertEquals(bitSize128, bf2.size());
+ Assert.assertTrue(bf2 instanceof jogamp.common.util.Int32ArrayBitfield);
+
+ // verify no bit is set
+ Assert.assertEquals(0, bf1.bitCount());
+ Assert.assertEquals(0, bf2.bitCount());
+
+ bf1.clearField(true);
+ bf2.clearField(true);
+ Assert.assertEquals(bf1.size(), bf1.bitCount());
+ Assert.assertEquals(bf2.size(), bf2.bitCount());
+
+ bf1.clearField(false);
+ bf2.clearField(false);
+ Assert.assertEquals(0, bf1.bitCount());
+ Assert.assertEquals(0, bf2.bitCount());
+ }
+ static class TestDataBF {
+ final int bitSize;
+ final int val;
+ final String pattern;
+ public TestDataBF(final int bitSize, final int value, final String pattern) {
+ this.bitSize = bitSize;
+ this.val = value;
+ this.pattern = pattern;
+ }
+ }
+ static TestDataBF[] testDataBF32Bit = {
+ new TestDataBF(32, BitDemoData.testIntMSB, BitDemoData.testStringMSB),
+ new TestDataBF(32, BitDemoData.testIntMSB_rev, BitDemoData.testStringMSB_rev),
+ new TestDataBF(32, BitDemoData.testIntLSB, BitDemoData.testStringLSB),
+ new TestDataBF(32, BitDemoData.testIntLSB_revByte, BitDemoData.testStringLSB_revByte),
+
+ // H->L : 0x04030201: 00000100 00000011 00000010 00000001
+ new TestDataBF(32, 0x04030201, "00000100000000110000001000000001"),
+
+ // H->L : 0xAFFECAFE: 10101111 11111110 11001010 11111110
+ new TestDataBF(32, 0xAFFECAFE, "10101111111111101100101011111110"),
+ // H->L : 0xDEADBEEF: 11011110 10101101 10111110 11101111
+ new TestDataBF(32, 0xDEADBEEF, "11011110101011011011111011101111")
+ };
+ static TestDataBF[] testDataBF16Bit = {
+ // H->L : 0x0201: 00000100 00000011 00000010 00000001
+ new TestDataBF(16, 0x0201, "0000001000000001"),
+ // H->L : 0x0403: 00000100 00000011
+ new TestDataBF(16, 0x0403, "0000010000000011"),
+
+ // H->L : 0xAFFE: 10101111 11111110
+ new TestDataBF(16, 0xAFFE, "1010111111111110"),
+ // H->L : 0xCAFE: 11001010 11111110
+ new TestDataBF(16, 0xCAFE, "1100101011111110"),
+
+ // H->L : 0xDEADBEEF: 11011110 10101101 10111110 11101111
+ new TestDataBF(16, 0xDEAD, "1101111010101101"),
+ new TestDataBF(16, 0xBEEF, "1011111011101111")
+ };
+ static TestDataBF[] testDataBF3Bit = {
+ new TestDataBF(3, 0x01, "001"),
+ new TestDataBF(3, 0x02, "010"),
+ new TestDataBF(3, 0x05, "101")
+ };
+
+ @Test
+ public void test20_ValidateTestData() {
+ for(int i=0; i<testDataBF32Bit.length; i++) {
+ test_ValidateTestData( testDataBF32Bit[i] );
+ }
+ for(int i=0; i<testDataBF16Bit.length; i++) {
+ test_ValidateTestData( testDataBF16Bit[i] );
+ }
+ for(int i=0; i<testDataBF3Bit.length; i++) {
+ test_ValidateTestData( testDataBF3Bit[i] );
+ }
+ }
+ static void test_ValidateTestData(final TestDataBF d) {
+ final int oneBitCount0 = Bitfield.Util.bitCount(d.val);
+ final int oneBitCount1 = BitDemoData.getOneBitCount(d.pattern);
+ Assert.assertEquals(oneBitCount1, oneBitCount0);
+ final String pattern0 = BitDemoData.toBinaryString(d.val, d.bitSize);
+ Assert.assertEquals(d.pattern, pattern0);
+ final int val1 = BitDemoData.toInteger(d.pattern);
+ Assert.assertEquals(d.val, val1);
+ Assert.assertEquals(d.bitSize, pattern0.length());
+ }
+
+ static void assertEquals(final Bitfield bf, final int bf_off, final int v, final String pattern, final int oneBitCount) {
+ final int len = pattern.length();
+ for(int i=0; i<len; i++) {
+ final boolean exp0 = 0 != ( v & ( 1 << i ) );
+ final boolean exp1 = '1' == pattern.charAt(len-1-i);
+ final boolean has = bf.get(i+bf_off);
+ final String msg = String.format("Pos %04d: Value 0x%08x / %s, c %d", i, v, pattern, oneBitCount);
+ Assert.assertEquals(msg, exp0, has);
+ Assert.assertEquals(msg, exp1, has);
+ }
+ }
+
+ @Test
+ public void test21_Aligned32bit() {
+ for(int i=0; i<testDataBF32Bit.length; i++) {
+ test_Aligned32bit( testDataBF32Bit[i] );
+ }
+ for(int i=0; i<testDataBF16Bit.length; i++) {
+ test_Aligned32bit( testDataBF16Bit[i] );
+ }
+ for(int i=0; i<testDataBF3Bit.length; i++) {
+ test_Aligned32bit( testDataBF3Bit[i] );
+ }
+ }
+ static int get32BitStorageSize(final int bits) {
+ final int units = Math.max(1, ( bits + 31 ) >>> 5);
+ return units << 5;
+ }
+ static void test_Aligned32bit(final TestDataBF d) {
+ final int oneBitCount = Bitfield.Util.bitCount(d.val);
+
+ final Bitfield bf1 = Bitfield.Factory.create(d.bitSize);
+ Assert.assertEquals(get32BitStorageSize(d.bitSize), bf1.size());
+ final Bitfield bf2 = Bitfield.Factory.create(d.bitSize+128);
+ Assert.assertEquals(get32BitStorageSize(d.bitSize+128), bf2.size());
+
+ bf1.put32( 0, d.bitSize, d.val);
+ Assert.assertEquals(d.val, bf1.get32( 0, d.bitSize));
+ Assert.assertEquals(oneBitCount, bf1.bitCount());
+ assertEquals(bf1, 0, d.val, d.pattern, oneBitCount);
+
+ bf2.put32( 0, d.bitSize, d.val);
+ Assert.assertEquals(d.val, bf2.get32( 0, d.bitSize));
+ Assert.assertEquals(oneBitCount*1, bf2.bitCount());
+ assertEquals(bf2, 0, d.val, d.pattern, oneBitCount);
+ bf2.put32(64, d.bitSize, d.val);
+ Assert.assertEquals(d.val, bf2.get32(64, d.bitSize));
+ Assert.assertEquals(oneBitCount*2, bf2.bitCount());
+ assertEquals(bf2, 64, d.val, d.pattern, oneBitCount);
+
+ Assert.assertEquals(d.val, bf2.copy32(0, 96, d.bitSize));
+ Assert.assertEquals(d.val, bf2.get32(96, d.bitSize));
+ Assert.assertEquals(oneBitCount*3, bf2.bitCount());
+ assertEquals(bf2, 96, d.val, d.pattern, oneBitCount);
+ }
+
+ @Test
+ public void test21_Unaligned() {
+ for(int i=0; i<testDataBF32Bit.length; i++) {
+ test_Unaligned(testDataBF32Bit[i]);
+ }
+ for(int i=0; i<testDataBF16Bit.length; i++) {
+ test_Unaligned(testDataBF16Bit[i]);
+ }
+ for(int i=0; i<testDataBF3Bit.length; i++) {
+ test_Unaligned( testDataBF3Bit[i] );
+ }
+ }
+ static void test_Unaligned(final TestDataBF d) {
+ final Bitfield bf1 = Bitfield.Factory.create(d.bitSize);
+ final Bitfield bf2 = Bitfield.Factory.create(d.bitSize+128);
+ Assert.assertEquals(get32BitStorageSize(d.bitSize), bf1.size());
+ Assert.assertEquals(get32BitStorageSize(d.bitSize+128), bf2.size());
+ test_Unaligned( d, bf1 );
+ test_Unaligned( d, bf2 );
+ }
+ static void test_Unaligned(final TestDataBF d, final Bitfield bf) {
+ final int maxBitpos = bf.size()-d.bitSize;
+ for(int i=0; i<=maxBitpos; i++) {
+ bf.clearField(false);
+ test_Unaligned(d, bf, i);
+ }
+ }
+ static void test_Unaligned(final TestDataBF d, final Bitfield bf, final int lowBitnum) {
+ final int maxBitpos = bf.size()-d.bitSize;
+ final int oneBitCount = Bitfield.Util.bitCount(d.val);
+
+ final String msg = String.format("Value 0x%08x / %s, l %d/%d, c %d, lbPos %d -> %d",
+ d.val, d.pattern, d.bitSize, bf.size(), oneBitCount, lowBitnum, maxBitpos);
+
+ //
+ // via put32
+ //
+ bf.put32( lowBitnum, d.bitSize, d.val);
+ for(int i=0; i<d.bitSize; i++) {
+ Assert.assertEquals(msg+", bitpos "+i, 0 != ( d.val & ( 1 << i ) ), bf.get(lowBitnum+i));
+ }
+ Assert.assertEquals(msg, d.val, bf.get32( lowBitnum, d.bitSize));
+ Assert.assertEquals(msg, oneBitCount, bf.bitCount());
+ assertEquals(bf, lowBitnum, d.val, d.pattern, oneBitCount);
+
+ //
+ // via copy32
+ //
+ if( lowBitnum < maxBitpos ) {
+ // copy bits 1 forward
+ // clear trailing orig bit
+ Assert.assertEquals(msg, d.val, bf.copy32(lowBitnum, lowBitnum+1, d.bitSize));
+ bf.clear(lowBitnum);
+ Assert.assertEquals(msg, d.val, bf.get32( lowBitnum+1, d.bitSize));
+ Assert.assertEquals(msg, oneBitCount, bf.bitCount());
+ assertEquals(bf, lowBitnum+1, d.val, d.pattern, oneBitCount);
+ }
+
+ // test put() return value (previous value)
+ bf.clearField(false);
+ Assert.assertEquals(msg+", bitpos "+0, false, bf.put(lowBitnum+0, true));
+ Assert.assertEquals(msg+", bitpos "+0, true, bf.put(lowBitnum+0, false));
+
+ //
+ // via put
+ //
+ for(int i=0; i<d.bitSize; i++) {
+ Assert.assertEquals(msg+", bitpos "+i, false, bf.put(lowBitnum+i, 0 != ( d.val & ( 1 << i ) )));
+ }
+ Assert.assertEquals(msg, d.val, bf.get32(lowBitnum, d.bitSize));
+ for(int i=0; i<d.bitSize; i++) {
+ Assert.assertEquals(msg+", bitpos "+i, 0 != ( d.val & ( 1 << i ) ), bf.get(lowBitnum+i));
+ }
+ Assert.assertEquals(msg, oneBitCount, bf.bitCount());
+ assertEquals(bf, lowBitnum, d.val, d.pattern, oneBitCount);
+
+ //
+ // via copy
+ //
+ if( lowBitnum < maxBitpos ) {
+ // copy bits 1 forward
+ // clear trailing orig bit
+ for(int i=d.bitSize-1; i>=0; i--) {
+ Assert.assertEquals(msg+", bitpos "+i, 0 != ( d.val & ( 1 << i ) ),
+ bf.copy(lowBitnum+i, lowBitnum+1+i) );
+ }
+ bf.clear(lowBitnum);
+ Assert.assertEquals(msg, d.val, bf.get32( lowBitnum+1, d.bitSize));
+ for(int i=0; i<d.bitSize; i++) {
+ Assert.assertEquals(msg+", bitpos "+i, 0 != ( d.val & ( 1 << i ) ), bf.get(lowBitnum+1+i));
+ }
+ Assert.assertEquals(msg, oneBitCount, bf.bitCount());
+ assertEquals(bf, lowBitnum+1, d.val, d.pattern, oneBitCount);
+ }
+
+ //
+ // via set/clear
+ //
+ bf.clearField(false);
+ for(int i=0; i<d.bitSize; i++) {
+ if( 0 != ( d.val & ( 1 << i ) ) ) {
+ bf.set(lowBitnum+i);
+ } else {
+ bf.clear(lowBitnum+i);
+ }
+ }
+ Assert.assertEquals(msg, d.val, bf.get32(lowBitnum, d.bitSize));
+ for(int i=0; i<d.bitSize; i++) {
+ Assert.assertEquals(msg+", bitpos "+i, 0 != ( d.val & ( 1 << i ) ), bf.get(lowBitnum+i));
+ }
+ Assert.assertEquals(msg, oneBitCount, bf.bitCount());
+ assertEquals(bf, lowBitnum, d.val, d.pattern, oneBitCount);
+
+ //
+ // Validate 'other bits' put32/get32
+ //
+ bf.clearField(false);
+ bf.put32( lowBitnum, d.bitSize, d.val);
+ checkOtherBits(d, bf, lowBitnum, msg, 0);
+
+ bf.clearField(true);
+ bf.put32( lowBitnum, d.bitSize, d.val);
+ checkOtherBits(d, bf, lowBitnum, msg, Bitfield.UNSIGNED_INT_MAX_VALUE);
+ }
+
+ static void checkOtherBits(final TestDataBF d, final Bitfield bf, final int lowBitnum, final String msg, final int expBits) {
+ final int highBitnum = lowBitnum + d.bitSize - 1;
+ // System.err.println(msg+": [0"+".."+"("+lowBitnum+".."+highBitnum+").."+(bf.size()-1)+"]");
+ for(int i=0; i<lowBitnum; i+=32) {
+ final int len = Math.min(32, lowBitnum-i);
+ final int val = bf.get32(i, len);
+ final int exp = expBits & Bitfield.Util.getBitMask(len);
+ // System.err.println(" <"+i+".."+(i+len-1)+">, exp "+BitDemoData.toHexString(exp));
+ Assert.assertEquals(msg+", bitpos "+i, exp, val);
+ }
+ for(int i=highBitnum+1; i<bf.size(); i+=32) {
+ final int len = Math.min(32, bf.size() - i);
+ final int val = bf.get32(i, len);
+ final int exp = expBits & Bitfield.Util.getBitMask(len);
+ // System.err.println(" <"+i+".."+(i+len-1)+">, exp "+BitDemoData.toHexString(exp));
+ Assert.assertEquals(msg+", bitpos "+i, exp, val);
+ }
+ }
+
+ public static void main(final String args[]) throws IOException {
+ final String tstname = TestBitfield00.class.getName();
+ org.junit.runner.JUnitCore.main(tstname);
+ }
+
+}
diff --git a/src/junit/com/jogamp/common/util/TestBitstream00.java b/src/junit/com/jogamp/common/util/TestBitstream00.java
index 920363b..a2fd095 100644
--- a/src/junit/com/jogamp/common/util/TestBitstream00.java
+++ b/src/junit/com/jogamp/common/util/TestBitstream00.java
@@ -40,7 +40,7 @@ import org.junit.Assert;
import com.jogamp.common.nio.Buffers;
import com.jogamp.common.os.Platform;
-import static com.jogamp.common.util.BitstreamData.*;
+import static com.jogamp.common.util.BitDemoData.*;
import com.jogamp.junit.util.SingletonJunitCase;
diff --git a/src/junit/com/jogamp/common/util/TestBitstream01.java b/src/junit/com/jogamp/common/util/TestBitstream01.java
index 49931a3..bff37e3 100644
--- a/src/junit/com/jogamp/common/util/TestBitstream01.java
+++ b/src/junit/com/jogamp/common/util/TestBitstream01.java
@@ -35,7 +35,7 @@ import org.junit.Assert;
import org.junit.Test;
import com.jogamp.junit.util.SingletonJunitCase;
-import static com.jogamp.common.util.BitstreamData.*;
+import static com.jogamp.common.util.BitDemoData.*;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
diff --git a/src/junit/com/jogamp/common/util/TestBitstream02.java b/src/junit/com/jogamp/common/util/TestBitstream02.java
index 16904a2..5e6da1c 100644
--- a/src/junit/com/jogamp/common/util/TestBitstream02.java
+++ b/src/junit/com/jogamp/common/util/TestBitstream02.java
@@ -37,7 +37,7 @@ import org.junit.Test;
import com.jogamp.common.nio.Buffers;
import com.jogamp.junit.util.SingletonJunitCase;
-import static com.jogamp.common.util.BitstreamData.*;
+import static com.jogamp.common.util.BitDemoData.*;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
diff --git a/src/junit/com/jogamp/common/util/TestBitstream03.java b/src/junit/com/jogamp/common/util/TestBitstream03.java
index a6129d8..bd09d4a 100644
--- a/src/junit/com/jogamp/common/util/TestBitstream03.java
+++ b/src/junit/com/jogamp/common/util/TestBitstream03.java
@@ -38,7 +38,7 @@ import org.junit.Test;
import com.jogamp.common.nio.Buffers;
import com.jogamp.junit.util.SingletonJunitCase;
-import static com.jogamp.common.util.BitstreamData.*;
+import static com.jogamp.common.util.BitDemoData.*;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
diff --git a/src/junit/com/jogamp/common/util/TestBitstream04.java b/src/junit/com/jogamp/common/util/TestBitstream04.java
index 47be38d..2302e2e 100644
--- a/src/junit/com/jogamp/common/util/TestBitstream04.java
+++ b/src/junit/com/jogamp/common/util/TestBitstream04.java
@@ -38,7 +38,7 @@ import org.junit.Test;
import com.jogamp.common.nio.Buffers;
import com.jogamp.junit.util.SingletonJunitCase;
-import static com.jogamp.common.util.BitstreamData.*;
+import static com.jogamp.common.util.BitDemoData.*;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
diff --git a/src/junit/com/jogamp/common/util/TestIOUtil01.java b/src/junit/com/jogamp/common/util/TestIOUtil01.java
index e85aa37..19bc8b0 100644
--- a/src/junit/com/jogamp/common/util/TestIOUtil01.java
+++ b/src/junit/com/jogamp/common/util/TestIOUtil01.java
@@ -35,6 +35,7 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.net.URISyntaxException;
import java.net.URLConnection;
import java.nio.ByteBuffer;
@@ -43,6 +44,9 @@ import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
+import com.jogamp.common.ExceptionUtils;
+import com.jogamp.common.net.URIDumpUtil;
+import com.jogamp.common.net.Uri;
import com.jogamp.common.os.MachineDataInfo;
import com.jogamp.common.os.Platform;
import com.jogamp.junit.util.SingletonJunitCase;
@@ -78,8 +82,86 @@ public class TestIOUtil01 extends SingletonJunitCase {
}
@Test
- public void testCopyStream01Array() throws IOException {
- final URLConnection urlConn = IOUtil.getResource(this.getClass(), tfilename);
+ public void test01CleanPathString() throws IOException, URISyntaxException {
+ {
+ final String input = "./dummy/nop/../a.txt";
+ final String expected = "dummy/a.txt";
+ Assert.assertEquals(expected, IOUtil.cleanPathString(input));
+ }
+ {
+ final String input = "../dummy/nop/../a.txt";
+ final String expected = "../dummy/a.txt";
+ Assert.assertEquals(expected, IOUtil.cleanPathString(input));
+ }
+ {
+ final String input = ".././dummy/nop/../a.txt";
+ final String expected = "../dummy/a.txt";
+ Assert.assertEquals(expected, IOUtil.cleanPathString(input));
+ }
+ {
+ final String input = "./../dummy/nop/../a.txt";
+ final String expected = "../dummy/a.txt";
+ Assert.assertEquals(expected, IOUtil.cleanPathString(input));
+ }
+ {
+ final String input = "../dummy/./nop/../a.txt";
+ final String expected = "../dummy/a.txt";
+ Assert.assertEquals(expected, IOUtil.cleanPathString(input));
+ }
+ {
+ final String input = "/dummy/nop/./../a.txt";
+ final String expected = "/dummy/a.txt";
+ Assert.assertEquals(expected, IOUtil.cleanPathString(input));
+ }
+ {
+ final String input = "dummy/../nop/./.././aaa/bbb/../../a.txt";
+ final String expected = "a.txt";
+ Assert.assertEquals(expected, IOUtil.cleanPathString(input));
+ }
+ {
+ final String input = "/dummy/../nop/./.././aaa/bbb/././ccc/../../../a.txt";
+ final String expected = "/a.txt";
+ Assert.assertEquals(expected, IOUtil.cleanPathString(input));
+ }
+ {
+ URISyntaxException use = null;
+ try {
+ // Error case!
+ final String input = "../../error.txt";
+ final String expected = "error.txt";
+ final String result = IOUtil.cleanPathString(input); // URISyntaxException
+ System.err.println("input : "+input);
+ System.err.println("expected: "+expected);
+ System.err.println("result : "+result);
+ Assert.assertEquals(expected, result);
+ } catch (final URISyntaxException _use) {
+ use = _use;
+ ExceptionUtils.dumpThrowable("", _use, 0, 3);
+ }
+ Assert.assertNotNull("URISyntaxException expected", use);
+ }
+ {
+ URISyntaxException use = null;
+ try {
+ // Error case!
+ final String input = ".././a/../../error.txt";
+ final String expected = "error.txt";
+ final String result = IOUtil.cleanPathString(input); // URISyntaxException
+ System.err.println("input : "+input);
+ System.err.println("expected: "+expected);
+ System.err.println("result : "+result);
+ Assert.assertEquals(expected, result);
+ } catch (final URISyntaxException _use) {
+ use = _use;
+ ExceptionUtils.dumpThrowable("", _use, 0, 3);
+ }
+ Assert.assertNotNull("URISyntaxException expected", use);
+ }
+ }
+
+ @Test
+ public void test11CopyStream01Array() throws IOException {
+ final URLConnection urlConn = IOUtil.getResource(tfilename, this.getClass().getClassLoader(), this.getClass());
Assert.assertNotNull(urlConn);
final BufferedInputStream bis = new BufferedInputStream( urlConn.getInputStream() );
final byte[] bb;
@@ -94,8 +176,8 @@ public class TestIOUtil01 extends SingletonJunitCase {
}
@Test
- public void testCopyStream02Buffer() throws IOException {
- final URLConnection urlConn = IOUtil.getResource(this.getClass(), tfilename);
+ public void test12CopyStream02Buffer() throws IOException {
+ final URLConnection urlConn = IOUtil.getResource(tfilename, this.getClass().getClassLoader(), this.getClass());
Assert.assertNotNull(urlConn);
final BufferedInputStream bis = new BufferedInputStream( urlConn.getInputStream() );
final ByteBuffer bb;
@@ -111,16 +193,16 @@ public class TestIOUtil01 extends SingletonJunitCase {
}
@Test
- public void testCopyStream03Buffer() throws IOException {
+ public void test13CopyStream03Buffer() throws IOException {
final String tfilename2 = "./test2.bin" ;
- final URLConnection urlConn1 = IOUtil.getResource(this.getClass(), tfilename);
+ final URLConnection urlConn1 = IOUtil.getResource(tfilename, this.getClass().getClassLoader(), this.getClass());
Assert.assertNotNull(urlConn1);
final File file2 = new File(tfilename2);
file2.deleteOnExit();
try {
IOUtil.copyURLConn2File(urlConn1, file2);
- final URLConnection urlConn2 = IOUtil.getResource(this.getClass(), tfilename2);
+ final URLConnection urlConn2 = IOUtil.getResource(tfilename2, this.getClass().getClassLoader(), this.getClass());
Assert.assertNotNull(urlConn2);
final BufferedInputStream bis = new BufferedInputStream( urlConn2.getInputStream() );
diff --git a/src/junit/com/jogamp/common/util/TestPlatform01.java b/src/junit/com/jogamp/common/util/TestPlatform01.java
index 6f1fe0e..bf3e79d 100644
--- a/src/junit/com/jogamp/common/util/TestPlatform01.java
+++ b/src/junit/com/jogamp/common/util/TestPlatform01.java
@@ -44,7 +44,7 @@ public class TestPlatform01 extends SingletonJunitCase {
@Test
public void testInfo00() {
System.err.println();
- System.err.println();
+ System.err.print(Platform.getNewline());
System.err.println("OS name/type: "+Platform.getOSName()+", "+Platform.getOSType());
System.err.println("OS version: "+Platform.getOSVersion()+", "+Platform.getOSVersionNumber());
System.err.println();
diff --git a/src/junit/com/jogamp/common/util/TestRunnableTask01.java b/src/junit/com/jogamp/common/util/TestRunnableTask01.java
index 76c2d2a..6fd8f19 100644
--- a/src/junit/com/jogamp/common/util/TestRunnableTask01.java
+++ b/src/junit/com/jogamp/common/util/TestRunnableTask01.java
@@ -60,7 +60,7 @@ public class TestRunnableTask01 extends SingletonJunitCase {
System.err.println("BB.0: "+syncObject);
synchronized (syncObject) {
System.err.println("BB.1: "+syncObject);
- new Thread(clientAction, Thread.currentThread().getName()+"-clientAction").start();
+ new InterruptSource.Thread(null, clientAction, Thread.currentThread().getName()+"-clientAction").start();
try {
System.err.println("BB.2");
syncObject.wait();
@@ -88,7 +88,7 @@ public class TestRunnableTask01 extends SingletonJunitCase {
System.err.println("BB.0: "+rTask.getSyncObject());
synchronized (rTask.getSyncObject()) {
System.err.println("BB.1: "+rTask.getSyncObject());
- new Thread(rTask, Thread.currentThread().getName()+"-clientAction").start();
+ new InterruptSource.Thread(null, rTask, Thread.currentThread().getName()+"-clientAction").start();
try {
System.err.println("BB.2");
rTask.getSyncObject().wait();
diff --git a/src/junit/com/jogamp/common/util/TestVersionSemantics.java b/src/junit/com/jogamp/common/util/TestVersionSemantics.java
index 6faa9a6..8e36684 100644
--- a/src/junit/com/jogamp/common/util/TestVersionSemantics.java
+++ b/src/junit/com/jogamp/common/util/TestVersionSemantics.java
@@ -66,9 +66,6 @@ import com.jogamp.junit.util.VersionSemanticsUtil;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestVersionSemantics extends SingletonJunitCase {
static final String jarFile = "gluegen-rt.jar";
- static final VersionNumberString preVersionNumber = new VersionNumberString("2.2.0");
- static final Delta.CompatibilityType expectedCompatibilityType = Delta.CompatibilityType.NON_BACKWARD_COMPATIBLE;
- // static final Delta.CompatibilityType expectedCompatibilityType = Delta.CompatibilityType.BACKWARD_COMPATIBLE_USER;
static final DiffCriteria diffCriteria = new SimpleDiffCriteria();
// static final DiffCriteria diffCriteria = new PublicDiffCriteria();
@@ -76,22 +73,55 @@ public class TestVersionSemantics extends SingletonJunitCase {
static final JogampVersion curVersion = GlueGenVersion.getInstance();
static final VersionNumberString curVersionNumber = new VersionNumberString(curVersion.getImplementationVersion());
- static final Set<String> excludes;
+ static final Set<String> excludesDefault;
static {
- excludes = new HashSet<String>();
- excludes.add("^\\Qjogamp/\\E.*$");
+ excludesDefault = new HashSet<String>();
+ excludesDefault.add("^\\Qjogamp/\\E.*$");
}
@Test
- public void testVersionLatest() throws IllegalArgumentException, IOException, URISyntaxException {
+ public void testVersionV220V221() throws IllegalArgumentException, IOException, URISyntaxException {
+ testVersions(diffCriteria, Delta.CompatibilityType.BACKWARD_COMPATIBLE_USER, "2.2.0", "2.2.1", excludesDefault);
+ }
+
+ @Test
+ public void testVersionV221V230() throws IllegalArgumentException, IOException, URISyntaxException {
+ testVersions(diffCriteria, Delta.CompatibilityType.NON_BACKWARD_COMPATIBLE, "2.2.1", "2.3.0", excludesDefault);
+ }
+
+ @Test
+ public void testVersionV230V232() throws IllegalArgumentException, IOException, URISyntaxException {
+ testVersions(diffCriteria, Delta.CompatibilityType.BACKWARD_COMPATIBLE_BINARY, "2.3.0", "2.3.2", excludesDefault);
+ }
+
+ void testVersions(final DiffCriteria diffCriteria, final Delta.CompatibilityType expectedCompatibilityType,
+ final String v1, final String v2, final Set<String> excludes)
+ throws IllegalArgumentException, IOException, URISyntaxException {
+ final VersionNumberString preVersionNumber = new VersionNumberString(v1);
+ final File previousJar = new File("lib/v"+v1+"/"+jarFile);
+
+ final VersionNumberString curVersionNumber = new VersionNumberString(v2);
+ final File currentJar = new File("lib/v"+v2+"/"+jarFile);
+
+ VersionSemanticsUtil.testVersion(diffCriteria, expectedCompatibilityType,
+ previousJar, preVersionNumber,
+ currentJar, curVersionNumber, excludes);
+ }
+
+ @Test
+ public void testVersionV232V24x() throws IllegalArgumentException, IOException, URISyntaxException {
+ final Delta.CompatibilityType expectedCompatibilityType = Delta.CompatibilityType.NON_BACKWARD_COMPATIBLE;
+ // final Delta.CompatibilityType expectedCompatibilityType = Delta.CompatibilityType.BACKWARD_COMPATIBLE_USER;
+ // final Delta.CompatibilityType expectedCompatibilityType = Delta.CompatibilityType.BACKWARD_COMPATIBLE_BINARY;
+ final VersionNumberString preVersionNumber = new VersionNumberString("2.3.2");
final File previousJar = new File("lib/v"+preVersionNumber.getVersionString()+"/"+jarFile);
final ClassLoader currentCL = TestVersionSemantics.class.getClassLoader();
VersionSemanticsUtil.testVersion(diffCriteria, expectedCompatibilityType,
previousJar, preVersionNumber,
- curVersion.getClass(), currentCL, curVersionNumber, excludes);
+ curVersion.getClass(), currentCL, curVersionNumber, excludesDefault);
}
public static void main(final String args[]) throws IOException {
diff --git a/src/junit/com/jogamp/common/util/locks/TestRecursiveLock01.java b/src/junit/com/jogamp/common/util/locks/TestRecursiveLock01.java
index 4508f94..7455618 100644
--- a/src/junit/com/jogamp/common/util/locks/TestRecursiveLock01.java
+++ b/src/junit/com/jogamp/common/util/locks/TestRecursiveLock01.java
@@ -38,6 +38,7 @@ import org.junit.Assert;
import org.junit.Test;
import com.jogamp.common.os.Platform;
+import com.jogamp.common.util.InterruptSource;
import com.jogamp.junit.util.SingletonJunitCase;
import org.junit.FixMethodOrder;
@@ -170,7 +171,7 @@ public class TestRecursiveLock01 extends SingletonJunitCase {
public final void action2Deferred(final int l, final YieldMode yieldMode) {
final Action2 action2 = new Action2(l, yieldMode);
- new Thread(action2, Thread.currentThread().getName()+"-deferred").start();
+ new InterruptSource.Thread(null, action2, Thread.currentThread().getName()+"-deferred").start();
}
public final void lock() {
@@ -296,14 +297,14 @@ public class TestRecursiveLock01 extends SingletonJunitCase {
final long t0 = System.currentTimeMillis();
final LockedObject lo = new LockedObject(implType, fair);
final LockedObjectRunner[] runners = new LockedObjectRunner[threadNum];
- final Thread[] threads = new Thread[threadNum];
+ final InterruptSource.Thread[] threads = new InterruptSource.Thread[threadNum];
int i;
for(i=0; i<threadNum; i++) {
runners[i] = new LockedObjectRunner1(lo, loops, iloops, yieldMode);
// String name = Thread.currentThread().getName()+"-ActionThread-"+i+"_of_"+threadNum;
final String name = "ActionThread-"+i+"_of_"+threadNum;
- threads[i] = new Thread( runners[i], name );
+ threads[i] = new InterruptSource.Thread( null, runners[i], name );
threads[i].start();
}
diff --git a/src/junit/com/jogamp/common/util/locks/TestRecursiveThreadGroupLock01.java b/src/junit/com/jogamp/common/util/locks/TestRecursiveThreadGroupLock01.java
index e35d146..30a0274 100644
--- a/src/junit/com/jogamp/common/util/locks/TestRecursiveThreadGroupLock01.java
+++ b/src/junit/com/jogamp/common/util/locks/TestRecursiveThreadGroupLock01.java
@@ -34,6 +34,7 @@ import org.junit.Assert;
import org.junit.Test;
import com.jogamp.common.os.Platform;
+import com.jogamp.common.util.InterruptSource;
import com.jogamp.junit.util.SingletonJunitCase;
import org.junit.FixMethodOrder;
@@ -239,15 +240,15 @@ public class TestRecursiveThreadGroupLock01 extends SingletonJunitCase {
final LockedObject lo = new LockedObject();
final LockedObjectRunner[] concurrentRunners = new LockedObjectRunner[concurrentThreadNum];
final LockedObjectRunner[] slaveRunners = new LockedObjectRunner[slaveThreadNum];
- final Thread[] concurrentThreads = new Thread[concurrentThreadNum];
- final Thread[] slaveThreads = new Thread[slaveThreadNum];
- final Thread[] noCoOwnerThreads = new Thread[0];
+ final InterruptSource.Thread[] concurrentThreads = new InterruptSource.Thread[concurrentThreadNum];
+ final InterruptSource.Thread[] slaveThreads = new InterruptSource.Thread[slaveThreadNum];
+ final InterruptSource.Thread[] noCoOwnerThreads = new InterruptSource.Thread[0];
int i;
for(i=0; i<slaveThreadNum; i++) {
slaveRunners[i] = new LockedObjectRunner1(" ", "s"+i, lo, loops, mark, yieldMode);
final String name = "ActionThread-Slaves-"+i+"_of_"+slaveThreadNum;
- slaveThreads[i] = new Thread( slaveRunners[i], name );
+ slaveThreads[i] = new InterruptSource.Thread( null, slaveRunners[i], name );
}
for(i=0; i<concurrentThreadNum; i++) {
String name;
@@ -258,7 +259,7 @@ public class TestRecursiveThreadGroupLock01 extends SingletonJunitCase {
concurrentRunners[i] = new LockedObjectRunner1(" ", "O"+i, lo, noCoOwnerThreads, loops, mark, yieldMode);
name = "ActionThread-Others-"+i+"_of_"+concurrentThreadNum;
}
- concurrentThreads[i] = new Thread( concurrentRunners[i], name );
+ concurrentThreads[i] = new InterruptSource.Thread( null, concurrentRunners[i], name );
concurrentThreads[i].start();
if(i==0) {
// master thread w/ slaves shall start first
diff --git a/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket00.java b/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket00.java
index b018a79..ce0087a 100644
--- a/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket00.java
+++ b/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket00.java
@@ -35,10 +35,12 @@ import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
+import com.jogamp.common.util.InterruptSource;
+import com.jogamp.junit.util.JunitTracer;
import com.jogamp.junit.util.SingletonJunitCase;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestSingletonServerSocket00 {
+public class TestSingletonServerSocket00 extends JunitTracer {
public static final long SINGLE_INSTANCE_LOCK_TO = SingletonJunitCase.SINGLE_INSTANCE_LOCK_TO;
public static final long SINGLE_INSTANCE_LOCK_POLL = 100; // poll every 100ms
@@ -69,7 +71,7 @@ public class TestSingletonServerSocket00 {
}
private Thread startLockUnlockOffThread(final int i) {
- final Thread t = new Thread(new Runnable() {
+ final Thread t = new InterruptSource.Thread(null, new Runnable() {
public void run() {
final SingletonInstance myLock = SingletonInstance.createServerSocket(10, SingletonJunitCase.SINGLE_INSTANCE_LOCK_PORT);
System.err.println(Thread.currentThread().getName()+" LOCK try ..");
diff --git a/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket01.java b/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket01.java
index b37e600..c637865 100644
--- a/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket01.java
+++ b/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket01.java
@@ -35,10 +35,11 @@ import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
+import com.jogamp.junit.util.JunitTracer;
import com.jogamp.junit.util.SingletonJunitCase;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestSingletonServerSocket01 {
+public class TestSingletonServerSocket01 extends JunitTracer {
private static volatile SingletonInstance singletonInstance;
@BeforeClass
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java
index 3b1857d..db8c157 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java
@@ -65,21 +65,25 @@ public class BaseClass extends SingletonJunitCase {
Assert.assertNotNull(ifName+" does not exist", clazzIf);
Assert.assertNotNull(implName+" does not exist", clazzImpl);
- Assert.assertEquals(1, clazzIf.getDeclaredField("CONSTANT_ONE").get(null));
+ Assert.assertNotNull(clazzImpl.getDeclaredMethod("nopTest"));
final Object obj = clazzImpl.newInstance();
Assert.assertTrue("Not of type "+ifName, clazzIf.isAssignableFrom(obj.getClass()));
- Assert.assertTrue("Not of type com.jogamp.gluegen.test.junit.generation.Bindingtest1", (obj instanceof com.jogamp.gluegen.test.junit.generation.Bindingtest1));
+ Assert.assertTrue("Not of type com.jogamp.gluegen.test.junit.generation.Bindingtest1",
+ (obj instanceof com.jogamp.gluegen.test.junit.generation.Bindingtest1));
}
+ public static final float EPSILON = 1.1920929E-7f; // Float.MIN_VALUE == 1.4e-45f ; double EPSILON 2.220446049250313E-16d
+
/**
* Verifies if all generated method signatures are completed,
* ie a compilation only coverage test without functional tests.
*/
public void chapter__TestCoverageSignature(final Bindingtest1 binding) throws Exception {
- int i;
+ int i = 0;
final long context = 0;
LongBuffer lb=null;
+ ByteBuffer bb=null;
final IntBuffer ib=null;
final long[] larray = null;
final int larray_offset = 0;
@@ -89,10 +93,42 @@ public class BaseClass extends SingletonJunitCase {
final int iarray_offset = 0;
long result = 0;
long l = result;
+ ShortBlob sb = null;
+ Int32Struct i32s = null;
+ AnonBlob ab = null;
+ PointerBuffer pb=null;
{
- final ByteBuffer bb = binding.createAPtrBlob();
- PointerBuffer pb = safeByteBuffer2PointerBuffer(bb, 1);
+ l = binding.testXID(l);
+ l = binding.testXID_2(l);
+
+ bb = binding.testAnonBuffer(bb);
+
+ sb = binding.testShortBlob(sb);
+ sb = binding.testLPShortBlob0(sb);
+ sb = binding.testLPShortBlob1(sb);
+ sb = binding.testLPShortBlob2(sb);
+ sb = binding.testLPShortBlob3(sb);
+ sb = binding.testShortBlobL1(sb);
+ sb = binding.testShortBlobL2(sb);
+
+ i32s = binding.testInt32Struct(i32s);
+
+ ab = binding.testCreateAnonBlob();
+ binding.testDestroyAnonBlob(ab);
+
+ l = binding.testCreateAnonBlob2();
+ binding.testDestroyAnonBlob2(l);
+
+ lb = binding.testFooPtr(larray, 0);
+ lb = binding.testFooPtr(lb);
+
+ i = binding.testDelegate(i);
+ }
+
+ {
+ bb = binding.createAPtrBlob();
+ pb = safeByteBuffer2PointerBuffer(bb, 1);
long bb2A = binding.getAPtrAddress(bb);
bb2A = bb2A - 0; // avoid warning
@@ -119,9 +155,6 @@ public class BaseClass extends SingletonJunitCase {
binding.releaseAPtrBlob(bb);
}
- final ByteBuffer bb=null;
- PointerBuffer pb=null;
-
result = binding.arrayTestInt32(context, ib);
result = binding.arrayTestInt32(context, iarray, iarray_offset);
@@ -177,6 +210,185 @@ public class BaseClass extends SingletonJunitCase {
l = binding.typeTestUIntPtrT(l, l);
}
+ /**
+ * Verifies if all generated static constant values are completed,
+ * and whether their value is as expected!
+ * <p>
+ * Covers all enumerates and defines.
+ * </p>
+ */
+ public void chapter01TestStaticConstants(final Bindingtest1 binding) throws Exception {
+ // Plain vanilla CPP constants
+ Assert.assertEquals( 1, Bindingtest1.CONSTANT_ONE);
+ Assert.assertEquals( 8, Bindingtest1.ARRAY_SIZE);
+ Assert.assertEquals(1234, Bindingtest1.DEFINE_01);
+
+ // Enums
+ Assert.assertEquals( 1, Bindingtest1.LI);
+ Assert.assertEquals( 3, Bindingtest1.LO);
+ Assert.assertEquals( 2, Bindingtest1.LU);
+ Assert.assertEquals( 1, Bindingtest1.MI);
+ Assert.assertEquals( 3, Bindingtest1.MO);
+ Assert.assertEquals( 2, Bindingtest1.MU);
+ Assert.assertEquals( 0, Bindingtest1.ZERO);
+ Assert.assertEquals( 1, Bindingtest1.ONE);
+ Assert.assertEquals( 2, Bindingtest1.TWO);
+ Assert.assertEquals( 3, Bindingtest1.THREE);
+
+ // CPP Macro Expansion!
+ Assert.assertEquals( 1, Bindingtest1.NUMBER_ONE);
+ Assert.assertEquals( 2, Bindingtest1.NUMBER_TWO);
+ Assert.assertEquals( 4, Bindingtest1.NUMBER_FOUR);
+ Assert.assertEquals( 5, Bindingtest1.NUMBER_FIVE);
+ Assert.assertEquals( 8, Bindingtest1.NUMBER_EIGHT);
+ Assert.assertEquals( 9, Bindingtest1.NUMBER_NINE);
+ Assert.assertEquals( 10, Bindingtest1.NUMBER_TEN);
+
+ // Enum Constant Expressions!
+ Assert.assertEquals( 1, Bindingtest1.ENUM_NUM_ONE);
+ Assert.assertEquals( 2, Bindingtest1.ENUM_NUM_TWO);
+ Assert.assertEquals( 3, Bindingtest1.ENUM_NUM_THREE);
+ Assert.assertEquals( 4, Bindingtest1.ENUM_NUM_FOUR);
+ Assert.assertEquals( 5, Bindingtest1.ENUM_NUM_FIVE);
+ Assert.assertEquals( 8, Bindingtest1.ENUM_NUM_EIGHT);
+ Assert.assertEquals( 9, Bindingtest1.ENUM_NUM_NINE);
+ Assert.assertEquals( 10, Bindingtest1.ENUM_NUM_TEN);
+
+ // Integer 32bit (int / enum)
+ final int ENUM_I0 = Bindingtest1.ENUM_I0;
+ final int ENUM_I1 = Bindingtest1.ENUM_I1;
+ final int ENUM_I2 = Bindingtest1.ENUM_I2;
+ final int ENUM_I3 = Bindingtest1.ENUM_I3;
+ final int ENUM_I4 = -Bindingtest1.ENUM_I4;
+ final int ENUM_I5 = -Bindingtest1.ENUM_I5;
+ final int ENUM_I6 = -Bindingtest1.ENUM_I6;
+ final int ENUM_I7 = Bindingtest1.ENUM_I7;
+ final int ENUM_I8 = Bindingtest1.ENUM_I8;
+ final int ENUM_I9 = Bindingtest1.ENUM_I9;
+ final int ENUM_IA = Bindingtest1.ENUM_IA;
+ final int ENUM_IB = Bindingtest1.ENUM_IB;
+ final int ENUM_IX = Bindingtest1.ENUM_IX;
+ int iexp = 10;
+ Assert.assertEquals(iexp++, ENUM_I0);
+ Assert.assertEquals(iexp++, ENUM_I1);
+ Assert.assertEquals(iexp++, ENUM_I2);
+ Assert.assertEquals(iexp++, ENUM_I3);
+ Assert.assertEquals(iexp++, ENUM_I4);
+ Assert.assertEquals(iexp++, ENUM_I5);
+ Assert.assertEquals(iexp++, ENUM_I6);
+ Assert.assertEquals(iexp++, ENUM_I7);
+ Assert.assertEquals(iexp++, ENUM_I8);
+ Assert.assertEquals(iexp++, ENUM_I9);
+ Assert.assertEquals(iexp++, ENUM_IA);
+ Assert.assertEquals(iexp++, ENUM_IB);
+ Assert.assertEquals(0xffffffff, ENUM_IX);
+
+ // Integer 32bit (int / define)
+ final int CL_INT_I0 = Bindingtest1.CL_INT_I0;
+ final int CL_INT_I1 = Bindingtest1.CL_INT_I1;
+ final int CL_INT_I2 = Bindingtest1.CL_INT_I2;
+ final int CL_INT_I3 = Bindingtest1.CL_INT_I3;
+ final int CL_INT_I4 = -Bindingtest1.CL_INT_I4;
+ final int CL_INT_I5 = -Bindingtest1.CL_INT_I5;
+ final int CL_INT_I6 = -Bindingtest1.CL_INT_I6;
+ final int CL_INT_I7 = -Bindingtest1.CL_INT_I7;
+ final int CL_INT_I8 = Bindingtest1.CL_INT_I8;
+ final int CL_INT_I9 = Bindingtest1.CL_INT_I9;
+ final int CL_INT_IA = Bindingtest1.CL_INT_IA;
+ final int CL_INT_IB = Bindingtest1.CL_INT_IB;
+ final int CL_INT_IX = Bindingtest1.CL_INT_IX;
+ iexp = 10;
+ Assert.assertEquals(iexp++, CL_INT_I0);
+ Assert.assertEquals(iexp++, CL_INT_I1);
+ Assert.assertEquals(iexp++, CL_INT_I2);
+ Assert.assertEquals(iexp++, CL_INT_I3);
+ Assert.assertEquals(iexp++, CL_INT_I4);
+ Assert.assertEquals(iexp++, CL_INT_I5);
+ Assert.assertEquals(iexp++, CL_INT_I6);
+ Assert.assertEquals(iexp++, CL_INT_I7);
+ Assert.assertEquals(iexp++, CL_INT_I8);
+ Assert.assertEquals(iexp++, CL_INT_I9);
+ Assert.assertEquals(iexp++, CL_INT_IA);
+ Assert.assertEquals(iexp++, CL_INT_IB);
+ Assert.assertEquals(0xffffffff, CL_INT_IX);
+
+ // Integer 64bit (long / define )
+ final long CL_LNG_L0 = Bindingtest1.CL_LNG_L0;
+ final long CL_LNG_L1 = Bindingtest1.CL_LNG_L1;
+ final long CL_LNG_L2 = Bindingtest1.CL_LNG_L2;
+ final long CL_LNG_L3 = Bindingtest1.CL_LNG_L3;
+ final long CL_LNG_L4 = -Bindingtest1.CL_LNG_L4;
+ final long CL_LNG_L5 = -Bindingtest1.CL_LNG_L5;
+ final long CL_LNG_L6 = -Bindingtest1.CL_LNG_L6;
+ final long CL_LNG_L7 = -Bindingtest1.CL_LNG_L7;
+ final long CL_LNG_L8 = Bindingtest1.CL_LNG_L8;
+ final long CL_LNG_L9 = Bindingtest1.CL_LNG_L9;
+ final long CL_LNG_LA = Bindingtest1.CL_LNG_LA;
+ final long CL_LNG_LB = Bindingtest1.CL_LNG_LB;
+ final long CL_LNG_LX = Bindingtest1.CL_LNG_LX;
+ long lexp = 2147483648L;
+ Assert.assertEquals(lexp++, CL_LNG_L0);
+ Assert.assertEquals(lexp++, CL_LNG_L1);
+ Assert.assertEquals(lexp++, CL_LNG_L2);
+ Assert.assertEquals(lexp++, CL_LNG_L3);
+ Assert.assertEquals(lexp++, CL_LNG_L4);
+ Assert.assertEquals(lexp++, CL_LNG_L5);
+ Assert.assertEquals(lexp++, CL_LNG_L6);
+ Assert.assertEquals(lexp++, CL_LNG_L7);
+ Assert.assertEquals(lexp++, CL_LNG_L8);
+ Assert.assertEquals(lexp++, CL_LNG_L9);
+ Assert.assertEquals(lexp++, CL_LNG_LA);
+ Assert.assertEquals(lexp++, CL_LNG_LB);
+ Assert.assertEquals(0xffffffffffffffffL, CL_LNG_LX);
+
+ // Floating point hexadecimals
+ final float CL_FLT_A0 = Bindingtest1.CL_FLT_A0;
+ final float CL_FLT_A1 = Bindingtest1.CL_FLT_A1;
+ final float CL_FLT_A2 = Bindingtest1.CL_FLT_A2;
+ final float CL_FLT_A3 = Bindingtest1.CL_FLT_A3;
+ final float CL_FLT_A4 = Bindingtest1.CL_FLT_A4;
+ final float CL_FLT_A5 = Bindingtest1.CL_FLT_A5;
+ final float CL_FLT_A6 = Bindingtest1.CL_FLT_A6;
+ final float CL_FLT_A7 = Bindingtest1.CL_FLT_A7;
+ Assert.assertEquals( 0x1.p127f, CL_FLT_A0, EPSILON);
+ Assert.assertEquals( 0x1.p+127F, CL_FLT_A1, EPSILON);
+ Assert.assertEquals( 0x1.p-127f, CL_FLT_A2, EPSILON);
+ Assert.assertEquals( -0.1f, CL_FLT_A3, EPSILON);
+ Assert.assertEquals( 0.2f, CL_FLT_A4, EPSILON);
+ Assert.assertEquals( 0.3f, CL_FLT_A5, EPSILON);
+ Assert.assertEquals( 0.4f, CL_FLT_A6, EPSILON);
+ Assert.assertEquals( 1.0f, CL_FLT_A7, EPSILON);
+
+ final float CL_FLT_EPSILON = Bindingtest1.CL_FLT_EPSILON;
+ final double CL_FLT_MAX= Bindingtest1.CL_FLT_MAX;
+ final double CL_FLT_MIN = Bindingtest1.CL_FLT_MIN;
+ Assert.assertEquals( 0x1.0p-23f, CL_FLT_EPSILON, EPSILON);
+ Assert.assertEquals( 0x1.fffffep127f, CL_FLT_MAX, EPSILON);
+ Assert.assertEquals( 0x1.0p-126f, CL_FLT_MIN, EPSILON);
+
+ final double CL_DBL_B0 = Bindingtest1.CL_DBL_B0;
+ final double CL_DBL_B1 = Bindingtest1.CL_DBL_B1;
+ final double CL_DBL_B2 = Bindingtest1.CL_DBL_B2;
+ final double CL_DBL_B3 = Bindingtest1.CL_DBL_B3;
+ final double CL_DBL_B4 = Bindingtest1.CL_DBL_B4;
+ final double CL_DBL_B5 = Bindingtest1.CL_DBL_B5;
+ final double CL_DBL_B6 = Bindingtest1.CL_DBL_B6;
+ Assert.assertEquals( 0x1.p127d, CL_DBL_B0, EPSILON);
+ Assert.assertEquals( 0x1.p+127D, CL_DBL_B1, EPSILON);
+ Assert.assertEquals( 0x1.p-127d, CL_DBL_B2, EPSILON);
+ Assert.assertEquals( -0.1, CL_DBL_B3, EPSILON);
+ Assert.assertEquals( 0.2, CL_DBL_B4, EPSILON);
+ Assert.assertEquals( 0.3, CL_DBL_B5, EPSILON);
+ Assert.assertEquals( 3.5e+38, CL_DBL_B6, EPSILON);
+
+ final float CL_DBL_EPSILON = Bindingtest1.CL_DBL_EPSILON;
+ final double CL_DBL_MAX= Bindingtest1.CL_DBL_MAX;
+ final double CL_DBL_MIN = Bindingtest1.CL_DBL_MIN;
+ Assert.assertEquals( 0x1.0p-52f, CL_DBL_EPSILON, EPSILON);
+ Assert.assertEquals( 0x1.fffffffffffffp1023, CL_DBL_MAX, EPSILON);
+ Assert.assertEquals( 0x1.0p-1022, CL_DBL_MIN, EPSILON);
+ }
+
ByteBuffer newByteBuffer(final int size, final boolean direct) {
if(direct) {
final ByteBuffer bb = Buffers.newDirectByteBuffer(size);
@@ -629,6 +841,66 @@ public class BaseClass extends SingletonJunitCase {
Assert.assertTrue("Wrong result: 0x"+Long.toHexString(pb.get(i))+"+1 != 0x"+Long.toHexString(pb2.get(i)), (pb.get(i)+1)==pb2.get(i));
}
}
+
+ {
+ final long l0 = 0xAAFFEE;
+ final long l1 = binding.testXID(l0);
+ final long l2 = binding.testXID_2(l0);
+ Assert.assertEquals(l0, l1);
+ Assert.assertEquals(l0, l2);
+
+ final ByteBuffer bb = Buffers.newDirectByteBuffer(PointerBuffer.ELEMENT_SIZE);
+ for(int j=0; j<bb.limit(); j++) {
+ bb.put(j, (byte)(0xAA+j));
+ }
+ final ByteBuffer bbOut = binding.testAnonBuffer(bb);
+ Assert.assertEquals(bb, bbOut);
+
+ final ShortBlob sb = ShortBlob.create();
+ sb.setB1((byte)0xAA);
+ sb.setB2((byte)0xEE);
+ final ShortBlob sb_ = binding.testShortBlob(sb);
+ final ShortBlob sb0 = binding.testLPShortBlob0(sb);
+ final ShortBlob sb1 = binding.testLPShortBlob1(sb);
+ final ShortBlob sb2 = binding.testLPShortBlob2(sb);
+ final ShortBlob sb3 = binding.testLPShortBlob3(sb);
+ final ShortBlob sb4 = binding.testShortBlobL1(sb);
+ final ShortBlob sb5 = binding.testShortBlobL2(sb);
+ Assert.assertEquals(sb.getBuffer(), sb_.getBuffer());
+ Assert.assertEquals(sb.getBuffer(), sb0.getBuffer());
+ Assert.assertEquals(sb.getBuffer(), sb1.getBuffer());
+ Assert.assertEquals(sb.getBuffer(), sb2.getBuffer());
+ Assert.assertEquals(sb.getBuffer(), sb3.getBuffer());
+ Assert.assertEquals(sb.getBuffer(), sb4.getBuffer());
+ Assert.assertEquals(sb.getBuffer(), sb5.getBuffer());
+
+ final Int32Struct i32s = Int32Struct.create();
+ i32s.setB1((byte)0x02);
+ i32s.setB2((byte)0x12);
+ i32s.setB3((byte)0x22);
+ i32s.setB4((byte)0x32);
+ final Int32Struct i32s0 = binding.testInt32Struct(i32s);
+ Assert.assertEquals(i32s.getBuffer(), i32s0.getBuffer());
+
+ final AnonBlob ab = binding.testCreateAnonBlob();
+ binding.testDestroyAnonBlob(ab);
+
+ final long ab2 = binding.testCreateAnonBlob2();
+ binding.testDestroyAnonBlob2(ab2);
+
+ final long[] foo = new long[] { 0x1122334455667788L };
+ final LongBuffer fooLB = Buffers.newDirectLongBuffer(foo);
+ final LongBuffer foo1Out = binding.testFooPtr(fooLB);
+ Assert.assertEquals(fooLB, foo1Out);
+ final LongBuffer foo2Out = binding.testFooPtr(foo, 0);
+ Assert.assertEquals(fooLB, foo2Out);
+ }
+
+ {
+ i=41;
+ final int iRes = binding.testDelegate(i);
+ Assert.assertEquals(i+1, iRes);
+ }
}
public void chapter04TestPointerBuffer(final Bindingtest1 binding) throws Exception {
@@ -1115,22 +1387,20 @@ public class BaseClass extends SingletonJunitCase {
}
}
- public static final float EPSILON = 1.1920929E-7f; // Float.MIN_VALUE == 1.4e-45f ; double EPSILON 2.220446049250313E-16d
-
/** Test array and pointer bindings of structs */
public void chapter12TestStructArrayModelConst(final Bindingtest1 binding) throws Exception {
final TK_ModelConst model = binding.createModelConst();
Assert.assertEquals(3, model.getIntxxPointerCustomLenVal());
Assert.assertEquals(3, model.getInt32PointerCustomLenVal());
- Assert.assertEquals(3, model.getInt32ArrayFixedLenArrayLength());
- Assert.assertEquals(3, model.getStructArrayFixedLenArrayLength());
+ Assert.assertEquals(3, TK_ModelConst.getInt32ArrayFixedLenArrayLength());
+ Assert.assertEquals(3, TK_ModelConst.getStructArrayFixedLenArrayLength());
Assert.assertEquals(3, model.getStructPointerCustomLenVal());
// field: int32ArrayFixedLen
// CType['int32_t *', size [fixed false, lnx64 12], [array*1]], with array length of 3
{
- final int size = model.getInt32ArrayFixedLenArrayLength();
+ final int size = TK_ModelConst.getInt32ArrayFixedLenArrayLength();
final int[] all = model.getInt32ArrayFixedLen(0, new int[size]);
final IntBuffer allB = model.getInt32ArrayFixedLen();
Assert.assertEquals(size, allB.limit());
@@ -1170,7 +1440,7 @@ public class BaseClass extends SingletonJunitCase {
// field: mat4x4
// CType['float * *', size [fixed false, lnx64 64], [array*2]], with array length of <code>4*4</code> */
{
- Assert.assertEquals(4*4, model.getMat4x4ArrayLength());
+ Assert.assertEquals(4*4, TK_ModelConst.getMat4x4ArrayLength());
final FloatBuffer mat4x4 = model.getMat4x4();
Assert.assertEquals(4*4, mat4x4.limit());
for(int i=0; i<4; i++) {
@@ -1185,7 +1455,7 @@ public class BaseClass extends SingletonJunitCase {
// field: structArrayFixedLen
// field: CType['TK_Dimension *', size [fixed false, lnx64 48], [array*1]], with array length of 3
{
- final int size = model.getStructArrayFixedLenArrayLength();
+ final int size = TK_ModelConst.getStructArrayFixedLenArrayLength();
final TK_Dimension[] all = model.getStructArrayFixedLen(0, new TK_Dimension[size]);
for(int i=0; i<size; i++) {
Assert.assertEquals(51 + i * 10, all[i].getX());
@@ -1236,7 +1506,7 @@ public class BaseClass extends SingletonJunitCase {
assertAPTR(surfaceContext, model.getCtx());
{
- Assert.assertEquals(12, model.getModelNameArrayFixedLenArrayLength());
+ Assert.assertEquals(12, TK_ModelConst.getModelNameArrayFixedLenArrayLength());
final ByteBuffer bb = model.getModelNameArrayFixedLen();
Assert.assertEquals(12, bb.limit());
@@ -1296,14 +1566,14 @@ public class BaseClass extends SingletonJunitCase {
Assert.assertEquals(3, model.getIntxxPointerCustomLenVal());
Assert.assertEquals(3, model.getInt32PointerCustomLenVal());
- Assert.assertEquals(3, model.getInt32ArrayFixedLenArrayLength());
- Assert.assertEquals(3, model.getStructArrayFixedLenArrayLength());
+ Assert.assertEquals(3, TK_ModelMutable.getInt32ArrayFixedLenArrayLength());
+ Assert.assertEquals(3, TK_ModelMutable.getStructArrayFixedLenArrayLength());
Assert.assertEquals(3, model.getStructPointerCustomLenVal());
// field: int32ArrayFixedLen
// CType['int32_t *', size [fixed false, lnx64 12], [array*1]], with array length of 3
{
- final int size = model.getInt32ArrayFixedLenArrayLength();
+ final int size = TK_ModelMutable.getInt32ArrayFixedLenArrayLength();
{
final int[] values = new int[] { 1, 2, 3 };
model.setInt32ArrayFixedLen(0, values);
@@ -1385,7 +1655,7 @@ public class BaseClass extends SingletonJunitCase {
model.setMat4x4(2*4, new float[] { 31, 32, 33, 34 } );
model.setMat4x4(3*4, new float[] { 41, 42, 43, 44 } );
- Assert.assertEquals(4*4, model.getMat4x4ArrayLength());
+ Assert.assertEquals(4*4, TK_ModelMutable.getMat4x4ArrayLength());
final FloatBuffer mat4x4 = model.getMat4x4();
Assert.assertEquals(4*4, mat4x4.limit());
for(int i=0; i<4; i++) {
@@ -1400,7 +1670,7 @@ public class BaseClass extends SingletonJunitCase {
// field: structArrayFixedLen
// field: CType['TK_Dimension *', size [fixed false, lnx64 48], [array*1]], with array length of 3
{
- final int size = model.getStructArrayFixedLenArrayLength();
+ final int size = TK_ModelMutable.getStructArrayFixedLenArrayLength();
{
for(int i=0; i<size; i++) {
final TK_Dimension d = TK_Dimension.create();
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java
index 9e961cb..5809acf 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java
@@ -50,7 +50,7 @@ public class Test1p1JavaEmitter extends BaseClass {
* Verifies loading of the new library.
*/
@BeforeClass
- public static void chapter01TestLoadLibrary() throws Exception {
+ public static void chapter__TestLoadLibrary() throws Exception {
BindingJNILibLoader.loadBindingtest1p1();
}
@@ -58,7 +58,7 @@ public class Test1p1JavaEmitter extends BaseClass {
* Verifies the existence and creation of the generated class.
*/
@Test
- public void chapter02TestClassExist() throws Exception {
+ public void chapter00TestClassExist() throws Exception {
testClassExist("test1p1");
}
@@ -71,6 +71,18 @@ public class Test1p1JavaEmitter extends BaseClass {
}
/**
+ * Verifies if all generated static constant values are completed,
+ * and whether their value is as expected!
+ * <p>
+ * Covers all enumerates and defines.
+ * </p>
+ */
+ @Test
+ public void chapter01TestStaticConstants() throws Exception {
+ chapter01TestStaticConstants(new Bindingtest1p1Impl());
+ }
+
+ /**
* Verifies if all methods / signatures are properly generated,
* can be invoked and functions.
* This is a compilation (coverage) and runtime time (semantic) test.
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2LoadJNIAndImplLib.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2LoadJNIAndImplLib.java
index b8adab0..e61c600 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2LoadJNIAndImplLib.java
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2LoadJNIAndImplLib.java
@@ -46,9 +46,9 @@ public class Test1p2LoadJNIAndImplLib extends BaseClass {
* Verifies loading of the new library.
*/
@BeforeClass
- public static void chapter01TestLoadLibrary() throws Exception {
+ public static void chapter__TestLoadLibrary() throws Exception {
BindingJNILibLoader.loadBindingtest1p2();
- dynamicLookupHelper = NativeLibrary.open("test1", Test1p2LoadJNIAndImplLib.class.getClassLoader(), true);
+ dynamicLookupHelper = NativeLibrary.open("test1", true, true, Test1p2LoadJNIAndImplLib.class.getClassLoader(), true);
Assert.assertNotNull("NativeLibrary.open(test1) failed", dynamicLookupHelper);
Bindingtest1p2Impl.resetProcAddressTable(dynamicLookupHelper);
@@ -58,17 +58,16 @@ public class Test1p2LoadJNIAndImplLib extends BaseClass {
* Verifies the existence and creation of the generated class.
*/
@Test
- public void chapter02TestClassExist() throws Exception {
+ public void chapter00TestClassExist() throws Exception {
testClassExist("test1p2");
}
-
@SuppressWarnings("unused")
public static void main(final String args[]) throws Exception {
if( true ) {
- chapter01TestLoadLibrary();
+ chapter__TestLoadLibrary();
final Test1p2LoadJNIAndImplLib tst = new Test1p2LoadJNIAndImplLib();
- tst.chapter02TestClassExist();
+ tst.chapter00TestClassExist();
} else {
final String tstname = Test1p2LoadJNIAndImplLib.class.getName();
org.junit.runner.JUnitCore.main(tstname);
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java
index 49a1851..fa99915 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java
@@ -30,6 +30,7 @@ package com.jogamp.gluegen.test.junit.generation;
import java.io.IOException;
+import com.jogamp.gluegen.test.junit.generation.impl.Bindingtest1p1Impl;
import com.jogamp.gluegen.test.junit.generation.impl.Bindingtest1p2Impl;
import com.jogamp.common.os.NativeLibrary;
@@ -54,9 +55,9 @@ public class Test1p2ProcAddressEmitter extends BaseClass {
* Verifies loading of the new library.
*/
@BeforeClass
- public static void chapter01TestLoadLibrary() throws Exception {
+ public static void chapter__TestLoadLibrary() throws Exception {
BindingJNILibLoader.loadBindingtest1p2();
- dynamicLookupHelper = NativeLibrary.open("test1", Test1p2ProcAddressEmitter.class.getClassLoader(), true);
+ dynamicLookupHelper = NativeLibrary.open("test1", false, false, Test1p2ProcAddressEmitter.class.getClassLoader(), true);
Assert.assertNotNull("NativeLibrary.open(test1) failed", dynamicLookupHelper);
Bindingtest1p2Impl.resetProcAddressTable(dynamicLookupHelper);
@@ -66,7 +67,7 @@ public class Test1p2ProcAddressEmitter extends BaseClass {
* Verifies the existence and creation of the generated class.
*/
@Test
- public void chapter02TestClassExist() throws Exception {
+ public void chapter00TestClassExist() throws Exception {
testClassExist("test1p2");
}
@@ -79,6 +80,18 @@ public class Test1p2ProcAddressEmitter extends BaseClass {
}
/**
+ * Verifies if all generated static constant values are completed,
+ * and whether their value is as expected!
+ * <p>
+ * Covers all enumerates and defines.
+ * </p>
+ */
+ @Test
+ public void chapter01TestStaticConstants() throws Exception {
+ chapter01TestStaticConstants(new Bindingtest1p2Impl());
+ }
+
+ /**
* Verifies if all methods / signatures are properly generated,
* can be invoked and functions.
* This is a compilation (coverage) and runtime time (semantic) test.
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1-CustomJavaCode.cfg b/src/junit/com/jogamp/gluegen/test/junit/generation/test1-CustomJavaCode.cfg
new file mode 100644
index 0000000..8d8f650
--- /dev/null
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1-CustomJavaCode.cfg
@@ -0,0 +1,7 @@
+
+@Override
+public int testDelegate(int v) {
+ return testDelegateOrigImpl(v) + 1;
+}
+
+
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg b/src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg
index 8e41aae..6c516c2 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg
@@ -32,10 +32,24 @@ ReturnValueCapacity typeTestAnonPointer ARRAY_SIZE * sizeof(MYAPIConfig)
Opaque long MYAPIConfig
Opaque boolean Bool
+Opaque long XID
+# For 'struct _AnonBlob2*', we need to drop 'struct'
+Opaque long _AnonBlob2*
+
+Opaque long _Crazy*;
+Opaque long ShortBlob.Cool
+
CustomCCode #include "test1.h"
Opaque long TK_Context
+RenameJavaSymbol DEFINE_01_EXT DEFINE_01
+RenameJavaSymbol testXID_EXT testXID
+
+DelegateImplementation testDelegate testDelegateOrigImpl
+IncludeAs CustomJavaCode Bindingtest1p1Impl test1-CustomJavaCode.cfg
+IncludeAs CustomJavaCode Bindingtest1p2Impl test1-CustomJavaCode.cfg
+
StructPackage TK_Dimension com.jogamp.gluegen.test.junit.generation
EmitStruct TK_Dimension
StructPackage TK_DimensionPair com.jogamp.gluegen.test.junit.generation
@@ -96,6 +110,9 @@ Import java.nio.*
Import java.util.*
Import com.jogamp.common.os.*
Import com.jogamp.common.nio.*
+Import com.jogamp.gluegen.test.junit.generation.ShortBlob
+Import com.jogamp.gluegen.test.junit.generation.Int32Struct
+Import com.jogamp.gluegen.test.junit.generation.AnonBlob
Import com.jogamp.gluegen.test.junit.generation.TK_Surface
Import com.jogamp.gluegen.test.junit.generation.TK_Dimension
Import com.jogamp.gluegen.test.junit.generation.TK_DimensionPair
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c
index 9999274..0683600 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c
@@ -8,10 +8,67 @@
#define DEBUG 1
+MYAPI XID MYAPIENTRY testXID(XID v) {
+ return v;
+}
+MYAPI XID_2 MYAPIENTRY testXID_2(XID_2 v) {
+ return v;
+}
+MYAPI AnonBuffer MYAPIENTRY testAnonBuffer(AnonBuffer v) {
+ return v;
+}
+
+MYAPI const ShortBlob * MYAPIENTRY testShortBlob(const ShortBlob *v) {
+ return v;
+}
+MYAPI const LPShortBlob0 MYAPIENTRY testLPShortBlob0(const LPShortBlob0 v) {
+ return v;
+}
+MYAPI LPShortBlob1 MYAPIENTRY testLPShortBlob1(LPShortBlob1 v) {
+ return v;
+}
+MYAPI const LPShortBlob2 MYAPIENTRY testLPShortBlob2(const LPShortBlob2 v) {
+ return v;
+}
+MYAPI LPShortBlob3 MYAPIENTRY testLPShortBlob3(LPShortBlob3 v) {
+ return v;
+}
+MYAPI const ShortBlobL1 * MYAPIENTRY testShortBlobL1(const ShortBlobL1 * v) {
+ return v;
+}
+MYAPI ShortBlobL2 * MYAPIENTRY testShortBlobL2(ShortBlobL2 * v) {
+ return v;
+}
+MYAPI struct Int32Struct * MYAPIENTRY testInt32Struct(struct Int32Struct * v) {
+ return v;
+}
+
+MYAPI AnonBlob MYAPIENTRY testCreateAnonBlob() {
+ return (AnonBlob) calloc(1, sizeof(char));
+}
+MYAPI void MYAPIENTRY testDestroyAnonBlob(AnonBlob v) {
+ free(v);
+}
+
+MYAPI struct _AnonBlob2 * MYAPIENTRY testCreateAnonBlob2() {
+ return (struct _AnonBlob2 *) calloc(1, sizeof(char));
+}
+MYAPI void MYAPIENTRY testDestroyAnonBlob2(struct _AnonBlob2 * v) {
+ free(v);
+}
+
+MYAPI foo_ptr MYAPIENTRY testFooPtr(foo_ptr v) {
+ return v;
+}
+
MYAPI foo MYAPIENTRY nopTest() {
return 42;
}
+MYAPI int32_t MYAPIENTRY testDelegate(int32_t v) {
+ return v;
+}
+
/**
* new blob sizeof(void*) filled w/ 0xDEADBEEF
*/
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
index 67a8050..4896165 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
@@ -28,12 +28,166 @@
typedef int Bool;
typedef uint64_t foo;
+typedef foo * foo_ptr;
typedef void * APtr1Type;
typedef intptr_t APtr2Type;
+typedef void * XID; // Opaque
+typedef XID XID_2; // Opaque, due to XID
+typedef void * AnonBuffer; // Non Opaque
+
+// typedef XID XID_2; // Duplicate w/ compatible type (ignored) - OpenSolaris: Native gcc error
+// typedef int XID_2; // Duplicate w/ incompatible type ERROR
+
+#define CL_INT_I0 10
+#define CL_INT_I1 11u
+#define CL_INT_I2 12U
+#define CL_INT_I3 0x0d
+#define CL_INT_I4 -14
+#define CL_INT_I5 -15u
+#define CL_INT_I6 -16U
+#define CL_INT_I7 -0x11U
+#define CL_INT_I8 +18
+#define CL_INT_I9 +19u
+#define CL_INT_IA +20U
+#define CL_INT_IB +0x15u
+#define CL_INT_IX 0xffffffffU
+
+enum CL_INT { ENUM_I0=10, ENUM_I1, ENUM_I2=+12U, ENUM_I3=0x0d, ENUM_I4=-14, ENUM_I5=-15u, ENUM_I6=-16U, ENUM_I7=0x11U,
+ ENUM_I8=+18, ENUM_I9=+19u, ENUM_IA, ENUM_IB=+0x15u, ENUM_IX=0xffffffffU };
+
+#define CL_LNG_L0 2147483648
+#define CL_LNG_L1 0x80000001ul
+#define CL_LNG_L2 2147483650UL
+#define CL_LNG_L3 0x80000003l
+#define CL_LNG_L4 -2147483652L
+#define CL_LNG_L5 -2147483653ul
+#define CL_LNG_L6 -2147483654lu
+#define CL_LNG_L7 -0x80000007UL
+#define CL_LNG_L8 +2147483656LU
+#define CL_LNG_L9 +2147483657uL
+#define CL_LNG_LA +2147483658lU
+#define CL_LNG_LB +0x8000000BLu
+#define CL_LNG_LX 0xffffffffffffffffUL
+
+#define CL_FLT_A0 0x1p127
+#define CL_FLT_A1 0x1p+127F
+#define CL_FLT_A2 +0x1p-127f
+#define CL_FLT_A3 -0.1
+#define CL_FLT_A4 0.2f
+#define CL_FLT_A5 0.3F
+#define CL_FLT_A6 .4
+#define CL_FLT_A7 1.0
+
+#define CL_DBL_B0 0x1.p127d
+#define CL_DBL_B1 0x1.p+127D
+#define CL_DBL_B2 +0x1.p-127d
+#define CL_DBL_B3 -0.1d
+#define CL_DBL_B4 0.2D
+#define CL_DBL_B5 .3D
+#define CL_DBL_B6 3.5e+38
+
+#define CL_FLT_MAX 0x1.fffffep127f
+#define CL_FLT_MIN 0x1.0p-126f
+#define CL_FLT_EPSILON 0x1.0p-23f
+
+#define CL_DBL_MAX 0x1.fffffffffffffp1023
+#define CL_DBL_MIN 0x1.0p-1022
+#define CL_DBL_EPSILON 0x1.0p-52
+
+#define DEFINE_01 1234
+#define DEFINE_01 1234 // Duplicate w/ same value (ignored)
+// #define DEFINE_01 1235 // Duplicate w/ diff value ERROR
+#define DEFINE_01_EXT 1234 // Renamed Duplicate w/ same value (ignored)
+// #define DEFINE_01_EXT 1235 // Renamed Duplicate w/ diff value ERROR
+// #define DEFINE_01 1235 // Duplicate w/ diff value ERROR
+
+#define DEFINE_02 ( (int ) 3 )
+// #define DEFINE_02 ( (int ) 3 ) // Duplicate w/ same value ERROR (PCPP redefine)
+// #define DEFINE_02 ( (int) 3 ) // Duplicate w/ diff value ERROR (PCPP redefine, then GlueGen)
+
+#define NUMBER_ONE CONSTANT_ONE
+#define NUMBER_TWO ( NUMBER_ONE + NUMBER_ONE )
+#define NUMBER_FOUR ( NUMBER_ONE << NUMBER_TWO )
+#define NUMBER_FIVE ( ( CONSTANT_ONE << NUMBER_TWO ) + NUMBER_ONE )
+#define NUMBER_EIGHT ( NUMBER_TWO * NUMBER_TWO + ( NUMBER_ONE << NUMBER_TWO ) )
+#define NUMBER_NINE ( 2 * 2 + ( 1 << 2 ) + 1 )
+#define NUMBER_TEN ( NUMBER_EIGHT | NUMBER_TWO )
+
+enum NumberOps { ENUM_NUM_ONE = CONSTANT_ONE,
+ ENUM_NUM_TWO = 1+1,
+ ENUM_NUM_THREE,
+ ENUM_NUM_FOUR = ( ENUM_NUM_ONE << ENUM_NUM_TWO ),
+ ENUM_NUM_FIVE = ( CONSTANT_ONE << ENUM_NUM_TWO ) + ENUM_NUM_ONE,
+ ENUM_NUM_EIGHT = ( ENUM_NUM_TWO * ENUM_NUM_TWO + ( ENUM_NUM_ONE << ENUM_NUM_TWO ) ),
+ ENUM_NUM_NINE = ( 2 * 2 + ( 1 << 2 ) + 1 ),
+ ENUM_NUM_TEN = ENUM_NUM_EIGHT |
+ ENUM_NUM_TWO
+ };
+
+enum Lala { LI=1, LU, LO };
+// enum Lala { LI=1, LU, LO }; // Duplicate w/ same value (ignored, ERROR in native compilation)
+// enum Lala { LI=1, LU=3, LO }; // Duplicate w/ diff value ERROR
+// enum Lala { LI=1, LU, LO, LERROR }; // Duplicate w/ diff value ERROR
+
+typedef enum { MI=1, MU, MO } Momo;
+// typedef enum { MI=1, MU, MO } Momo; // Duplicate w/ same value (ignored, ERROR in native compilation)
+// typedef enum { MI=1, MU=3, MO } Momo; // Duplicate w/ diff value ERROR
+// typedef enum { MI=1, MU, MO, MERR } Momo; // Duplicate w/ diff value ERROR
+
+struct _Crazy;
+
+typedef struct _ShortBlob {
+ uint8_t b1;
+ uint8_t b2;
+ struct _Crazy * Cool; // Opaque field!
+} ShortBlob, ShortBlob2, *LPShortBlob0; // Aliased to 'ShortBlob'
+typedef ShortBlob * LPShortBlob1; // Aliased to 'ShortBlob'
+typedef ShortBlob2 * LPShortBlob2; // Aliased to 'ShortBlob'
+typedef LPShortBlob1 LPShortBlob3; // Aliased to 'ShortBlob'
+typedef ShortBlob ShortBlobL1; // Aliased to 'ShortBlob'
+typedef ShortBlob2 ShortBlobL2; // Aliased to 'ShortBlob'
+
+struct Int32Struct {
+ uint8_t b1;
+ uint8_t b2;
+ uint8_t b3;
+ uint8_t b4;
+};
+
+typedef struct _AnonBlob * AnonBlob; // Anonymous-Struct, Non Opaque
+
+struct _AnonBlob2; // opaque: struct _AnonBlob2*
+
+MYAPI XID MYAPIENTRY testXID(XID v);
+MYAPI XID MYAPIENTRY testXID(XID_2 v); // duplicate: shall be dropped
+// MYAPI XID MYAPIENTRY testXID(int v); // duplicate w/ diff value ERROR
+MYAPI XID MYAPIENTRY testXID_EXT(XID v); // renamed duplicate w/ compat value: shall be dropped
+// MYAPI XID MYAPIENTRY testXID_EXT(int v); // renamed duplicate w/ diff value ERROR
+MYAPI XID_2 MYAPIENTRY testXID_2(XID_2 v);
+MYAPI AnonBuffer MYAPIENTRY testAnonBuffer(AnonBuffer v);
+MYAPI const ShortBlob * MYAPIENTRY testShortBlob(const ShortBlob *v);
+MYAPI const LPShortBlob0 MYAPIENTRY testLPShortBlob0(const LPShortBlob0 v);
+MYAPI LPShortBlob1 MYAPIENTRY testLPShortBlob1(LPShortBlob1 v);
+MYAPI const LPShortBlob2 MYAPIENTRY testLPShortBlob2(const LPShortBlob2 v);
+MYAPI LPShortBlob3 MYAPIENTRY testLPShortBlob3(LPShortBlob3 v);
+MYAPI const ShortBlobL1 * MYAPIENTRY testShortBlobL1(const ShortBlobL1 *v);
+MYAPI ShortBlobL2 * MYAPIENTRY testShortBlobL2(ShortBlobL2 *v);
+MYAPI struct Int32Struct * MYAPIENTRY testInt32Struct(struct Int32Struct * v);
+
+MYAPI AnonBlob MYAPIENTRY testCreateAnonBlob();
+MYAPI void MYAPIENTRY testDestroyAnonBlob(AnonBlob v);
+
+MYAPI struct _AnonBlob2 * MYAPIENTRY testCreateAnonBlob2();
+MYAPI void MYAPIENTRY testDestroyAnonBlob2(struct _AnonBlob2 * v);
+
+MYAPI foo_ptr MYAPIENTRY testFooPtr(foo_ptr v);
+
/** Returns 42 */
MYAPI foo MYAPIENTRY nopTest();
+MYAPI int32_t MYAPIENTRY testDelegate(int32_t v);
+
//
// Different pointer type tests ..
//
@@ -131,7 +285,7 @@ MYAPI int MYAPIENTRY intArrayCopy(int * dest, const int * src, int num);
/** Increases the elements by 1, and returns the sum
MYAPI int MYAPIENTRY intArrayWrite(int * * ints, int num); */
-typedef struct __MYAPIConfig * MYAPIConfig;
+typedef struct __MYAPIConfig * MYAPIConfig; // anonymous-struct opaque
/** Returns the passed MYAPIConfig incremented by 1 */
MYAPI MYAPIConfig MYAPIENTRY typeTestAnonSingle(const MYAPIConfig a);
@@ -172,7 +326,7 @@ typedef struct {
int32_t height;
} TK_Dimension;
-typedef struct _TK_Context * TK_Context; // anonymous
+typedef struct _TK_Context * TK_Context; // anonymous-struct opaque
typedef struct {
TK_Context ctx;
@@ -246,9 +400,12 @@ typedef struct {
int32_t i2;
} TK_DimensionPair;
+// some implicity _local_ typedef -> public typedef checks
+typedef TK_Surface * (MYAPIENTRY* PFNCREATESURFACEPROC)();
+typedef void (MYAPIENTRY* PFNDESTROYSURFACEPROC)(TK_Surface * surface);
+
MYAPI TK_Surface * MYAPIENTRY createSurface();
MYAPI void MYAPIENTRY destroySurface(TK_Surface * surface);
-
MYAPI TK_ComplicatedSuperSet * MYAPIENTRY createComplicatedSuperSet();
MYAPI Bool MYAPIENTRY hasInitValues(TK_ComplicatedSuperSet * s);
MYAPI void MYAPIENTRY destroyComplicatedSuperSet(TK_ComplicatedSuperSet * s);
@@ -266,6 +423,13 @@ MYAPI TK_Dimension MYAPIENTRY addDimensions(const TK_Dimension s[TWO]);
MYAPI TK_Dimension MYAPIENTRY addDimensionPair(const TK_DimensionPair s);
MYAPI void MYAPIENTRY zeroDimensions(TK_Dimension s[2]);
+
+// some implicity _local_ typedef -> public typedef checks
+typedef void (MYAPIENTRY* PFNCOPYPRIMTODIMENSIONSPROC)(const int pos[2], const int size[2], TK_Dimension dest[1]);
+typedef int (MYAPIENTRY* PFNRGBATOINTPROC)(const char rgba[4]);
+typedef void (MYAPIENTRY* PFNINTTORGBAPROC)(int irgba, char rgbaSink[4]);
+typedef void (MYAPIENTRY* PFNADDBYTEPROC)(const char summands[2], char result[1]);
+
MYAPI void MYAPIENTRY copyPrimToDimensions(const int pos[2], const int size[2], TK_Dimension dest[1]);
MYAPI void MYAPIENTRY copyDimensionsToPrim(TK_Dimension dim, int dpos[2], int dsize[2]);
MYAPI int MYAPIENTRY rgbaToInt(const char rgba[4]);
@@ -296,7 +460,7 @@ typedef struct {
const int32_t structPointerCustomLenVal;
const TK_Dimension * structPointerOneElem;
- const TK_Context ctx;
+ TK_Context ctx;
const char modelNameArrayFixedLen[12]; /* 'Hello Array' len=11+1 */
const char * modelNamePointerCString; /* 'Hello CString' len=13+1 */
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
index 6ef171b..b8582a8 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1p1-gluegen.cfg
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1p1-gluegen.cfg
@@ -6,6 +6,8 @@ NativeOutputDir native
Extends Bindingtest1p1 Bindingtest1
+ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/com/jogamp/gluegen/test/junit/generation/Bindingtest1.java
+
Include test1-common.cfg
Import com.jogamp.gluegen.test.junit.generation.Bindingtest1
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1p2-gluegen.cfg b/src/junit/com/jogamp/gluegen/test/junit/generation/test1p2-gluegen.cfg
index 708bd26..eb9fdcf 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1p2-gluegen.cfg
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1p2-gluegen.cfg
@@ -6,6 +6,8 @@ NativeOutputDir native
Extends Bindingtest1p2 Bindingtest1
+ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/com/jogamp/gluegen/test/junit/generation/Bindingtest1.java
+
# Use a ProcAddressTable so we dynamically look up the routines
EmitProcAddressTable true
ProcAddressTableClassName Bindingtest1p2ProcAddressTable
diff --git a/src/junit/com/jogamp/gluegen/test/junit/internals/TestType.java b/src/junit/com/jogamp/gluegen/test/junit/internals/TestType.java
new file mode 100644
index 0000000..84fc463
--- /dev/null
+++ b/src/junit/com/jogamp/gluegen/test/junit/internals/TestType.java
@@ -0,0 +1,85 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.gluegen.test.junit.internals;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.jogamp.gluegen.cgram.types.FloatType;
+import com.jogamp.gluegen.cgram.types.IntType;
+import com.jogamp.junit.util.SingletonJunitCase;
+
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestType extends SingletonJunitCase {
+
+ @Test
+ public void test01Equals() {
+ final FloatType f1 = new FloatType("GLfloat", null, 0, null);
+ final FloatType f2 = new FloatType("float", null, 0, null);
+ final IntType i1 = new IntType("GLint", null, false, 0, null);
+ final IntType i2 = new IntType("int", null, false, 0, null);
+ final int f1H = f1.hashCode();
+ final int f2H = f2.hashCode();
+ final int i1H = i1.hashCode();
+ final int i2H = i2.hashCode();
+
+ final int f1HS = f1.hashCodeSemantics();
+ final int f2HS = f2.hashCodeSemantics();
+ final int i1HS = i1.hashCodeSemantics();
+ final int i2HS = i2.hashCodeSemantics();
+
+ Assert.assertFalse(f1.getClass().isInstance(null));
+ Assert.assertTrue(f1.getClass().isInstance(f2));
+ Assert.assertTrue(i1.getClass().isInstance(i2));
+ Assert.assertFalse(f1.getClass().isInstance(i2));
+
+ Assert.assertFalse(f1.equals(f2));
+ Assert.assertFalse(i1.equals(i2));
+ Assert.assertFalse(f1.equals(i2));
+ Assert.assertNotEquals(f1H, f2H);
+ Assert.assertNotEquals(i1H, i2H);
+ Assert.assertNotEquals(f1H, i2H);
+
+ Assert.assertTrue(f1.equalSemantics(f2));
+ Assert.assertTrue(i1.equalSemantics(i2));
+ Assert.assertFalse(f1.equalSemantics(i2));
+ Assert.assertEquals(f1HS, f2HS);
+ Assert.assertEquals(i1HS, i2HS);
+ Assert.assertNotEquals(f1HS, i2HS);
+ }
+
+ public static void main(final String args[]) {
+ final String tstname = TestType.class.getName();
+ org.junit.runner.JUnitCore.main(tstname);
+ }
+
+}
diff --git a/src/junit/com/jogamp/junit/sec/Applet01.java b/src/junit/com/jogamp/junit/sec/Applet01.java
index f028d7c..fd13207 100644
--- a/src/junit/com/jogamp/junit/sec/Applet01.java
+++ b/src/junit/com/jogamp/junit/sec/Applet01.java
@@ -201,7 +201,7 @@ public class Applet01 extends Applet {
final Uri absLib = libDir1.concat(Uri.Encoded.cast("natives/" + libBaseName));
Exception sec01 = null;
try {
- final NativeLibrary nlib = NativeLibrary.open(absLib.toFile().getPath(), cl);
+ final NativeLibrary nlib = NativeLibrary.open(absLib.toFile().getPath(), true, true, cl, true);
System.err.println("NativeLibrary: "+nlib);
} catch (final SecurityException e) {
sec01 = e;
diff --git a/src/junit/com/jogamp/junit/sec/TestSecIOUtil01.java b/src/junit/com/jogamp/junit/sec/TestSecIOUtil01.java
index b3a1877..27f8d0b 100644
--- a/src/junit/com/jogamp/junit/sec/TestSecIOUtil01.java
+++ b/src/junit/com/jogamp/junit/sec/TestSecIOUtil01.java
@@ -183,7 +183,7 @@ public class TestSecIOUtil01 extends SingletonJunitCase {
Exception se0 = null;
NativeLibrary nlib = null;
try {
- nlib = NativeLibrary.open(absLib.toFile().getPath(), cl);
+ nlib = NativeLibrary.open(absLib.toFile().getPath(), true, true, cl, true);
System.err.println("NativeLibrary: "+nlib);
} catch (final SecurityException e) {
se0 = e;
diff --git a/src/junit/com/jogamp/junit/util/SingletonJunitCase.java b/src/junit/com/jogamp/junit/util/SingletonJunitCase.java
index 7fb5fea..ad80bde 100644
--- a/src/junit/com/jogamp/junit/util/SingletonJunitCase.java
+++ b/src/junit/com/jogamp/junit/util/SingletonJunitCase.java
@@ -45,19 +45,29 @@ public abstract class SingletonJunitCase extends JunitTracer {
private static SingletonInstance singletonInstance = null; // system wide lock via port locking
private static final Object singletonSync = new Object(); // classloader wide lock
+ private static boolean enabled = true;
+
+ /**
+ * Default is {@code true}.
+ */
+ public static final void enableSingletonLock(final boolean v) {
+ enabled = v;
+ }
@BeforeClass
public static final void oneTimeSetUpSingleton() {
// one-time initialization code
synchronized( singletonSync ) {
- if( null == singletonInstance ) {
- System.err.println("++++ Test Singleton.ctor()");
- // singletonInstance = SingletonInstance.createFileLock(SINGLE_INSTANCE_LOCK_POLL, SINGLE_INSTANCE_LOCK_FILE);
- singletonInstance = SingletonInstance.createServerSocket(SINGLE_INSTANCE_LOCK_POLL, SINGLE_INSTANCE_LOCK_PORT);
- }
- System.err.println("++++ Test Singleton.lock()");
- if(!singletonInstance.tryLock(SINGLE_INSTANCE_LOCK_TO)) {
- throw new RuntimeException("Fatal: Could not lock single instance: "+singletonInstance.getName());
+ if( enabled ) {
+ if( null == singletonInstance ) {
+ System.err.println("++++ Test Singleton.ctor()");
+ // singletonInstance = SingletonInstance.createFileLock(SINGLE_INSTANCE_LOCK_POLL, SINGLE_INSTANCE_LOCK_FILE);
+ singletonInstance = SingletonInstance.createServerSocket(SINGLE_INSTANCE_LOCK_POLL, SINGLE_INSTANCE_LOCK_PORT);
+ }
+ System.err.println("++++ Test Singleton.lock()");
+ if(!singletonInstance.tryLock(SINGLE_INSTANCE_LOCK_TO)) {
+ throw new RuntimeException("Fatal: Could not lock single instance: "+singletonInstance.getName());
+ }
}
}
}
@@ -67,12 +77,14 @@ public abstract class SingletonJunitCase extends JunitTracer {
// one-time cleanup code
synchronized( singletonSync ) {
System.gc(); // force cleanup
- System.err.println("++++ Test Singleton.unlock()");
- singletonInstance.unlock();
- try {
- // allowing other JVM instances to pick-up socket
- Thread.sleep( SINGLE_INSTANCE_LOCK_POLL );
- } catch (final InterruptedException e) { }
+ if( enabled ) {
+ System.err.println("++++ Test Singleton.unlock()");
+ singletonInstance.unlock();
+ try {
+ // allowing other JVM instances to pick-up socket
+ Thread.sleep( SINGLE_INSTANCE_LOCK_POLL );
+ } catch (final InterruptedException e) { }
+ }
}
}
}
diff --git a/src/junit/com/jogamp/junit/util/VersionSemanticsUtil.java b/src/junit/com/jogamp/junit/util/VersionSemanticsUtil.java
index 78f4460..de850d0 100644
--- a/src/junit/com/jogamp/junit/util/VersionSemanticsUtil.java
+++ b/src/junit/com/jogamp/junit/util/VersionSemanticsUtil.java
@@ -86,16 +86,18 @@ public class VersionSemanticsUtil {
}
System.err.println("Semantic Version Test");
- System.err.println("Previous version: "+preVersionNumber+" - "+previousJar.toString());
- System.err.println("Current version: "+curVersionNumber+" - "+currentJar.toString());
- System.err.println("Compat. expected: "+expectedCompatibilityType);
- System.err.println("Compat. detected: "+detectedCompatibilityType);
- System.err.println("Compat. result: detected "+compS+" expected -> "+(compOK ? "OK" : "ERROR"));
+ System.err.println(" criteria: "+diffCriteria);
+ System.err.println(" Previous version: "+preVersionNumber+" - "+previousJar.toString());
+ System.err.println(" Current version: "+curVersionNumber+" - "+currentJar.toString());
+ System.err.println(" Field values changed: "+delta.fieldCompatChanged());
+ System.err.println(" Compat. expected: "+expectedCompatibilityType);
+ System.err.println(" Compat. detected: "+detectedCompatibilityType);
+ System.err.println(" Compat. result: detected "+compS+" expected -> "+(compOK ? "OK" : "ERROR"));
final String resS;
if( compOK ) {
- resS = "Current version "+curVersionNumber+" is "+expectedCompatibilityType+" to previous version "+preVersionNumber+", actually "+detectedCompatibilityType;
+ resS = " Current version "+curVersionNumber+" is "+expectedCompatibilityType+" to previous version "+preVersionNumber+", actually "+detectedCompatibilityType;
} else {
- resS = "Current version "+curVersionNumber+" is not "+expectedCompatibilityType+" to previous version "+preVersionNumber+", but "+detectedCompatibilityType;
+ resS = " Current version "+curVersionNumber+" is not "+expectedCompatibilityType+" to previous version "+preVersionNumber+", but "+detectedCompatibilityType;
}
System.err.println(resS);
System.err.printf("%n%n");