summaryrefslogtreecommitdiffstats
path: root/src/junit
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2015-03-05 07:14:04 +0100
committerSven Gothel <[email protected]>2015-03-05 07:14:04 +0100
commit72d3635279ffc8ad88e47dff9bbe95d211226d11 (patch)
tree62b3735680dfc5980a94afa14c56045bd082af24 /src/junit
parentdd2440cbadc642a561d8f92c502fe822b2f11762 (diff)
Bug 1134 - Enhance GlueGen Compiler: Minimal GL Header Changes _and_ Typesafety
- We shall be able to import 'most' vanilla GL header, i.e. only change the typedef part using our GlueGen types - Type Safety: - GlueGen now detects '#define' and 'enum' redefines and throw an exception in this case. This helps detecting wrongly renamed GL extensions into core! - GlueGen now detects function redefines (overloading) and throw an exception in this case. Hence the semantics of duplicate functions has to be equal! This helps detecting wrongly renamed GL extensions into core! - Semantic equality for all types is provided via interface TypeComparator.SemanticEqualityOp, i.e. 'boolean equalSemantics(..)' implemented by com.jogamp.gluegen.cgram.types.Type. Semantic equality can be relaxed via config "RelaxedEqualSemanticsTest true", i.e. ignoring integer size, and const / volatile qualifiers. - All equality/hash methods of 'com.jogamp.gluegen.cgram.types.*' are restructured. - Track and simplify renamed 'symbol', i.e. use a common sub-interface for all renamed symbols (ConstantDefinition, FunctionSymbol, ..) - This is provided in a unified manner via interface com.jogamp.gluegen.cgram.types.AliasedSymbol and its common implementation AliasedSymbolImpl - All JavaConfiguration.shouldIgnore* methods operate w/ 'AliasedSymbol' trying to match all aliases. - Support 'struct NAME [ { ... } ]' w/o typedef's - New GL / CL headers do not use typedef's for anonymous opaque types - Opaque Type handling - JavaConfiguration.typeInfo(..), identifying opaque types, no more back references from target-type -> typedef. Hence the following is possible now: typedef void * Opaque01; // Opaque typedef void * APointerBuffer; // A Buffer - All Logger instances are no more static and derive their warning level from the package's root Logger via Logging.getLogger(..).
Diffstat (limited to 'src/junit')
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java109
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg10
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1.c46
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1.h73
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/internals/TestType.java85
5 files changed, 305 insertions, 18 deletions
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..4564019 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java
@@ -80,6 +80,7 @@ public class BaseClass extends SingletonJunitCase {
int i;
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 +90,38 @@ 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.testShortBlob0(sb);
+ sb = binding.testShortBlob1(sb);
+ sb = binding.testShortBlob2(sb);
+ sb = binding.testShortBlob3(sb);
+ sb = binding.testShortBlob4(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);
+ }
+
+ {
+ bb = binding.createAPtrBlob();
+ pb = safeByteBuffer2PointerBuffer(bb, 1);
long bb2A = binding.getAPtrAddress(bb);
bb2A = bb2A - 0; // avoid warning
@@ -119,9 +148,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);
@@ -629,6 +655,57 @@ 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 sb0 = binding.testShortBlob0(sb);
+ final ShortBlob sb1 = binding.testShortBlob1(sb);
+ final ShortBlob sb2 = binding.testShortBlob2(sb);
+ final ShortBlob sb3 = binding.testShortBlob3(sb);
+ final ShortBlob sb4 = binding.testShortBlob4(sb);
+ 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());
+
+ 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);
+ }
+
}
public void chapter04TestPointerBuffer(final Bindingtest1 binding) throws Exception {
@@ -1123,14 +1200,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_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 +1247,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 +1262,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 +1313,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 +1373,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 +1462,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 +1477,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/test1-common.cfg b/src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg
index 8e41aae..7210940 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,17 @@ 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*
+
CustomCCode #include "test1.h"
Opaque long TK_Context
+RenameJavaSymbol DEFINE_01_EXT DEFINE_01
+RenameJavaSymbol testXID_EXT testXID
+
StructPackage TK_Dimension com.jogamp.gluegen.test.junit.generation
EmitStruct TK_Dimension
StructPackage TK_DimensionPair com.jogamp.gluegen.test.junit.generation
@@ -96,6 +103,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..894dc10 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c
@@ -8,6 +8,52 @@
#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 testShortBlob0(const ShortBlob *v) {
+ return v;
+}
+MYAPI LPShortBlob1 MYAPIENTRY testShortBlob1(LPShortBlob1 v) {
+ return v;
+}
+MYAPI LPShortBlob2 MYAPIENTRY testShortBlob2(LPShortBlob2 v) {
+ return v;
+}
+MYAPI LPShortBlob3 MYAPIENTRY testShortBlob3(LPShortBlob3 v) {
+ return v;
+}
+MYAPI LPShortBlob4 MYAPIENTRY testShortBlob4(LPShortBlob4 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;
}
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..50f43b7 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
@@ -28,9 +28,78 @@
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)
+// typedef int XID_2; // Duplicate w/ incompatible type ERROR
+
+#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_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)
+
+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
+
+typedef struct _ShortBlob {
+ uint8_t b1;
+ uint8_t b2;
+} ShortBlob, ShortBlob2, *LPShortBlob1; // Aliased to 'ShortBlob'
+typedef ShortBlob2 * LPShortBlob2; // Aliased to 'ShortBlob'
+typedef ShortBlob * LPShortBlob3; // Aliased to 'ShortBlob'
+typedef LPShortBlob1 LPShortBlob4; // 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 testShortBlob0(const ShortBlob *v);
+MYAPI LPShortBlob1 MYAPIENTRY testShortBlob1(LPShortBlob1 v);
+MYAPI LPShortBlob2 MYAPIENTRY testShortBlob2(LPShortBlob2 v);
+MYAPI LPShortBlob3 MYAPIENTRY testShortBlob3(LPShortBlob3 v);
+MYAPI LPShortBlob4 MYAPIENTRY testShortBlob4(LPShortBlob4 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();
@@ -131,7 +200,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 +241,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;
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..1b83d0c
--- /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);
+ final FloatType f2 = new FloatType("float", null, 0);
+ final IntType i1 = new IntType("GLint", null, false, 0);
+ final IntType i2 = new IntType("int", null, false, 0);
+ 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);
+ }
+
+}