GlueGen v2.6.0-rc-20250712
GlueGen, Native Binding Generator for Java™ (public API).
StructValidator.java
Go to the documentation of this file.
1/**
2 * Copyright 2010 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;
30
31import java.lang.reflect.InvocationTargetException;
32import org.junit.Ignore;
33
34import static org.junit.Assert.*;
35
36/**
37 * this file will not compile unless {@link com.jogamp.gluegen.TestStructAccessor} has been run.
38 * @author Michael Bien
39 */
40@Ignore
41public class StructValidator {
42
43 // invoked via reflection from StructAccessorTest1
44 public static void validate() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, ClassNotFoundException {
45
46 System.out.println("validating struct accessors...");
47
48 final float[] mu = new float[] {1, 2, 3, 4};
49 final float[] light = new float[] {5, 6, 7};
50 final int fastRendering = 1;
51 final int shadow = 42;
52 final int iterations = 512;
53 final int sss = 12;
54 final float epsilon = (float) Math.PI;
55 final int height = 640;
56 final int width = 480;
57
58 final structtest.RenderingConfig config = structtest.RenderingConfig.create();
59
60 //set
61 config.setLight(light);
62 config.setMu(mu);
63 config.setActvateFastRendering(fastRendering);
64 config.setEnableShadow(shadow);
65 config.setMaxIterations(iterations);
66 config.setEpsilon(epsilon);
67 config.setSuperSamplingSize(sss);
68 config.setWidth(width);
69 config.setHeight(height);
70
71 final structtest.Camera camera = config.getCamera();
72 camera.getOrig().setX(1001).setY(1002).setZ(1003);
73 camera.getDir().setX(2001).setY(2002).setZ(2003);
74
75 //get and validate
76 assertArrayEquals(mu, config.getMu());
77 assertArrayEquals(light, config.getLight());
78
79 assertEquals(fastRendering, config.getActvateFastRendering());
80 assertEquals(shadow, config.getEnableShadow());
81 assertEquals(iterations, config.getMaxIterations());
82 assertEquals(epsilon, config.getEpsilon(), 0.01f);
83 assertEquals(sss, config.getSuperSamplingSize());
84 assertEquals(width, config.getWidth());
85 assertEquals(height, config.getHeight());
86
87 assertEquals(camera.getOrig().getX(), 1001, 0.001);
88 assertEquals(camera.getOrig().getY(), 1002, 0.001);
89 assertEquals(camera.getOrig().getZ(), 1003, 0.001);
90
91 assertEquals(camera.getDir().getX(), 2001, 0.001);
92 assertEquals(camera.getDir().getY(), 2002, 0.001);
93 assertEquals(camera.getDir().getZ(), 2003, 0.001);
94
95 System.out.println("done");
96
97 }
98
99 private static final void assertArrayEquals(final float[] a, final float[] b) {
100 for (int i = 0; i < b.length; i++) {
101 assertEquals(a[i], b[i], 0.0001f);
102 }
103 }
104
105}
this file will not compile unless com.jogamp.gluegen.TestStructAccessor has been run.