Skip to content

Commit

Permalink
Test: add a FatalError() method
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Nov 25, 2024
1 parent b7144d4 commit 82a3a38
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/test/java/testjoltjni/app/samples/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ abstract public class Test {
protected PhysicsSystem mPhysicsSystem;
protected TempAllocator mTempAllocator;
public void Cleanup(){}
protected void FatalError(String message){throw new RuntimeException(message);}
float GetWorldScale() { return 1.0f; }
public void Initialize(){}
public void PostPhysicsUpdate(float deltaTime){}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void PrePhysicsUpdate( PreUpdateParams inParams)

// Before update we may have some false hits, check that there are less hits after update than before
if (num_after > num_before)
throw new RuntimeException("BroadPhaseInsertionTest: After has more hits than before");
FatalError("BroadPhaseInsertionTest: After has more hits than before");
for (BroadPhaseCastResult ra : results_after)
{
boolean found = false;
Expand All @@ -143,7 +143,7 @@ public void PrePhysicsUpdate( PreUpdateParams inParams)
break;
}
if (!found)
throw new RuntimeException("BroadPhaseInsertionTest: Result after not found in result before");
FatalError("BroadPhaseInsertionTest: Result after not found in result before");
}

// Validate with brute force approach
Expand All @@ -161,12 +161,12 @@ public void PrePhysicsUpdate( PreUpdateParams inParams)
&& rayAaBoxHits(ray.getOrigin(), ray.getDirection(), b.getWorldSpaceBounds().getMin(), b.getWorldSpaceBounds().getMax()))
{
if (!found)
throw new RuntimeException("BroadPhaseInsertionTest: Is intersecting but was not found");
FatalError("BroadPhaseInsertionTest: Is intersecting but was not found");
}
else
{
if (found)
throw new RuntimeException("BroadPhaseInsertionTest: Is not intersecting but was found");
FatalError("BroadPhaseInsertionTest: Is not intersecting but was found");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ else if(supportsObjectStream())
// Load scene
PhysicsSceneRef scene=new PhysicsSceneRef();
if (!ObjectStreamIn.sReadObject((String)("Assets/") + sSceneName + ".bof", scene))
throw new RuntimeException("Failed to load scene");
FatalError("Failed to load scene");
scene.fixInvalidScales();
for (BodyCreationSettings settings : scene.getBodies())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ void CreateConvexOnTerrain1()
// Load scene
PhysicsSceneRef scene=new PhysicsSceneRef();
if (!ObjectStreamIn.sReadObject("Assets/terrain1.bof", scene))
throw new RuntimeException("Failed to load scene");
FatalError("Failed to load scene");
for (BodyCreationSettings body : scene.getBodies())
body.setObjectLayer ( Layers.NON_MOVING);
scene.fixInvalidScales();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ else if (supportsObjectStream())
// Load scene
PhysicsSceneRef scene=new PhysicsSceneRef();
if (!ObjectStreamIn.sReadObject("Assets/" + sSceneName + ".bof", scene))
throw new RuntimeException("Failed to load scene");
FatalError("Failed to load scene");
for (BodyCreationSettings body : scene.getBodies())
body.setObjectLayer(Layers.NON_MOVING);
scene.fixInvalidScales();
Expand Down

0 comments on commit 82a3a38

Please sign in to comment.