Skip to content

Commit

Permalink
test/junit: add tests for 6 new constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Sep 19, 2024
1 parent cdba58d commit 4891d5c
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 4 deletions.
26 changes: 24 additions & 2 deletions src/test/java/testjoltjni/junit/Test006.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,13 @@ of this software and associated documentation files (the "Software"), to deal
import com.github.stephengold.joltjni.StaticCompoundShapeSettings;
import com.github.stephengold.joltjni.TaperedCapsuleShapeSettings;
import com.github.stephengold.joltjni.TaperedCylinderShapeSettings;
import com.github.stephengold.joltjni.Triangle;
import com.github.stephengold.joltjni.Vec3;
import com.github.stephengold.joltjni.VertexList;
import com.github.stephengold.joltjni.readonly.Vec3Arg;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import testjoltjni.TestUtils;
Expand Down Expand Up @@ -130,7 +133,14 @@ private static void doConvexHullShapeSettings() {
testConvexHullSsDefaults(settings);
testConvexHullSsSetters(settings);

TestUtils.testClose(settings);
List<Vec3Arg> list = new ArrayList<>(1);
list.add(new Vec3());
ConvexHullShapeSettings settings2 = new ConvexHullShapeSettings(list);

testConvexHullSsDefaults(settings2);
testConvexHullSsSetters(settings2);

TestUtils.testClose(settings2, settings);
System.gc();
}

Expand Down Expand Up @@ -188,7 +198,19 @@ private static void doMeshShapeSettings() {
testMeshSsDefaults(settings);
testMeshSsSetters(settings);

TestUtils.testClose(settings, indices);
Triangle[] array = new Triangle[0];
MeshShapeSettings settings2 = new MeshShapeSettings(array);

testMeshSsDefaults(settings2);
testMeshSsSetters(settings2);

List<Triangle> list = new ArrayList<>(1);
MeshShapeSettings settings3 = new MeshShapeSettings(list);

testMeshSsDefaults(settings3);
testMeshSsSetters(settings3);

TestUtils.testClose(settings3, settings2, settings, indices);
System.gc();
}

Expand Down
49 changes: 47 additions & 2 deletions src/test/java/testjoltjni/junit/Test007.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,15 @@ of this software and associated documentation files (the "Software"), to deal
import com.github.stephengold.joltjni.TaperedCapsuleShapeSettings;
import com.github.stephengold.joltjni.TaperedCylinderShape;
import com.github.stephengold.joltjni.TaperedCylinderShapeSettings;
import com.github.stephengold.joltjni.Triangle;
import com.github.stephengold.joltjni.Vec3;
import com.github.stephengold.joltjni.VertexList;
import com.github.stephengold.joltjni.enumerate.EShapeSubType;
import com.github.stephengold.joltjni.enumerate.EShapeType;
import com.github.stephengold.joltjni.readonly.Vec3Arg;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import testjoltjni.TestUtils;
Expand Down Expand Up @@ -168,7 +171,21 @@ private static void doConvexHullShape() {

testConvexHullDefaults(shape);

TestUtils.testClose(shape, ref, result, settings);
List<Vec3Arg> list = new ArrayList<>(4);
list.add(new Vec3(3f, 3f, 3f));
list.add(new Vec3(-3f, 3f, -3f));
list.add(new Vec3(3f, -3f, -3f));
list.add(new Vec3(-3f, -3f, 3f));
settings = new ConvexHullShapeSettings(list);
result = settings.create();
Assert.assertFalse(result.hasError());
Assert.assertTrue(result.isValid());
ref = result.get();
ConvexHullShape shape2 = (ConvexHullShape) ref.getPtr();

testConvexHullDefaults(shape2);

TestUtils.testClose(shape2, shape, ref, result, settings);
System.gc();
}

Expand Down Expand Up @@ -271,7 +288,35 @@ private static void doMeshShape() {

testMeshDefaults(shape);

TestUtils.testClose(
Float3 v0 = new Float3(1f, 0f, 1f);
Float3 v1 = new Float3(1f, 0f, -1f);
Float3 v2 = new Float3(-1f, 0f, 1f);
Float3 v3 = new Float3(-1f, 0f, -1f);
Triangle tri1 = new Triangle(v0, v2, v3);
Triangle tri2 = new Triangle(v3, v1, v0);
List<Triangle> list = new ArrayList<>(2);
list.add(tri1);
list.add(tri2);
settings = new MeshShapeSettings(list);
result = settings.create();
Assert.assertFalse(result.hasError());
Assert.assertTrue(result.isValid());
ref = result.get();
MeshShape shape2 = (MeshShape) ref.getPtr();

testMeshDefaults(shape2);

Triangle[] array = {tri1, tri2};
settings = new MeshShapeSettings(array);
result = settings.create();
Assert.assertFalse(result.hasError());
Assert.assertTrue(result.isValid());
ref = result.get();
MeshShape shape3 = (MeshShape) ref.getPtr();

testMeshDefaults(shape3);

TestUtils.testClose(shape3, shape2, tri2, tri1,
shape, ref, result, settings, triangle2, triangle1, indices);
System.gc();
}
Expand Down

0 comments on commit 4891d5c

Please sign in to comment.