GlueGen v2.6.0-rc-20250712
GlueGen, Native Binding Generator for Java™ (public API).
TestType.java
Go to the documentation of this file.
1/**
2 * Copyright 2011 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28
29package com.jogamp.gluegen.test.junit.internals;
30
31import org.junit.Assert;
32import org.junit.Test;
33
34import com.jogamp.gluegen.cgram.types.FloatType;
35import com.jogamp.gluegen.cgram.types.IntType;
36import com.jogamp.junit.util.SingletonJunitCase;
37
38import org.junit.FixMethodOrder;
39import org.junit.runners.MethodSorters;
40
41@FixMethodOrder(MethodSorters.NAME_ASCENDING)
42public class TestType extends SingletonJunitCase {
43
44 @Test
45 public void test01Equals() {
46 final FloatType f1 = new FloatType("GLfloat", null, 0, null);
47 final FloatType f2 = new FloatType("float", null, 0, null);
48 final IntType i1 = new IntType("GLint", null, false, 0, null);
49 final IntType i2 = new IntType("int", null, false, 0, null);
50 final int f1H = f1.hashCode();
51 final int f2H = f2.hashCode();
52 final int i1H = i1.hashCode();
53 final int i2H = i2.hashCode();
54
55 final int f1HS = f1.hashCodeSemantics();
56 final int f2HS = f2.hashCodeSemantics();
57 final int i1HS = i1.hashCodeSemantics();
58 final int i2HS = i2.hashCodeSemantics();
59
60 Assert.assertFalse(f1.getClass().isInstance(null));
61 Assert.assertTrue(f1.getClass().isInstance(f2));
62 Assert.assertTrue(i1.getClass().isInstance(i2));
63 Assert.assertFalse(f1.getClass().isInstance(i2));
64
65 Assert.assertFalse(f1.equals(f2));
66 Assert.assertFalse(i1.equals(i2));
67 Assert.assertFalse(f1.equals(i2));
68 Assert.assertNotEquals(f1H, f2H);
69 Assert.assertNotEquals(i1H, i2H);
70 Assert.assertNotEquals(f1H, i2H);
71
72 Assert.assertTrue(f1.equalSemantics(f2));
73 Assert.assertTrue(i1.equalSemantics(i2));
74 Assert.assertFalse(f1.equalSemantics(i2));
75 Assert.assertEquals(f1HS, f2HS);
76 Assert.assertEquals(i1HS, i2HS);
77 Assert.assertNotEquals(f1HS, i2HS);
78 }
79
80 public static void main(final String args[]) {
81 final String tstname = TestType.class.getName();
82 org.junit.runner.JUnitCore.main(tstname);
83 }
84
85}
Represents a single-word floating-point type (C type "float".)
Definition: FloatType.java:47
final int hashCodeSemantics()
Semantic hashcode for Types exclusive its given name.
Definition: Type.java:497
final int hashCode()
Hashcode for Types.
Definition: Type.java:446
final boolean equalSemantics(final SemanticEqualityOp arg)
Semantic equality test for Types exclusive its given name.
Definition: Type.java:514
final boolean equals(final Object arg)
Equality test for Types inclusive its given name.
Definition: Type.java:468
static void main(final String args[])
Definition: TestType.java:80