Skip to content

Commit

Permalink
Test003: test the CollisionGroup class
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Nov 5, 2024
1 parent 1a7fa02 commit 17454d7
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/test/java/testjoltjni/junit/Test003.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ of this software and associated documentation files (the "Software"), to deal
import com.github.stephengold.joltjni.BodyCreationSettings;
import com.github.stephengold.joltjni.BoxShape;
import com.github.stephengold.joltjni.BoxShapeSettings;
import com.github.stephengold.joltjni.CollisionGroup;
import com.github.stephengold.joltjni.ContactSettings;
import com.github.stephengold.joltjni.GroupFilterTable;
import com.github.stephengold.joltjni.JobSystem;
import com.github.stephengold.joltjni.JobSystemSingleThreaded;
import com.github.stephengold.joltjni.JobSystemThreadPool;
Expand Down Expand Up @@ -76,6 +78,7 @@ public void test003() {

doAaBox();
doBodyCreationSettings();
doCollisionGroup();
doContactSettings();
doJobSystemSingleThreaded();
doJobSystemThreadPool();
Expand Down Expand Up @@ -191,6 +194,19 @@ private static void doBodyCreationSettings() {
System.gc();
}

/**
* Test the {@code CollisionGroup} class.
*/
private static void doCollisionGroup() {
CollisionGroup group = new CollisionGroup();

testCollisionGroupDefaults(group);
testCollisionGroupSetters(group);

TestUtils.testClose(group);
System.gc();
}

/**
* Test the {@code ContactSettings} class.
*/
Expand Down Expand Up @@ -392,6 +408,34 @@ private static void testBcsSetters(BodyCreationSettings bcs) {
TestUtils.assertEquals(0.6f, 0f, 0f, 0.8f, bcs.getRotation(), 0f);
}

/**
* Test the getters and defaults of the specified {@code CollisionGroup}.
*
* @param group the group to test (not null, unaffected)
*/
private static void testCollisionGroupDefaults(CollisionGroup group) {
Assert.assertNull(group.getGroupFilter());
Assert.assertEquals(CollisionGroup.cInvalidGroup, group.getGroupId());
Assert.assertEquals(
CollisionGroup.cInvalidGroup, group.getSubGroupId());
}

/**
* Test the setters of the specified {@code CollisionGroup}.
*
* @param group the group to test (not null)
*/
private static void testCollisionGroupSetters(CollisionGroup group) {
GroupFilterTable filter = new GroupFilterTable();
group.setGroupFilter(filter);
group.setGroupId(101);
group.setSubGroupId(102);

Assert.assertEquals(filter.va(), group.getGroupFilter().va());
Assert.assertEquals(101, group.getGroupId());
Assert.assertEquals(102, group.getSubGroupId());
}

/**
* Test the getters and defaults of the specified {@code ContactSettings}.
*
Expand Down

0 comments on commit 17454d7

Please sign in to comment.