Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unit test cleanup #102

Merged
merged 4 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ TODO for 0.5.0
- [WARNING] bootstrap class path not set in conjunction with -source 8
when using: mvn clean install -P on-jdk-9-plus
- CI: Fail build on warning?!
- CI: remove "temurin"...?!
- What is the deal with DJoint PARAM vs PARAM_N?
ODE doesn´t have PARAM_N (e.g. dParamBounce1)! -> ode4j shouldn´;t have them either...
Remove (deprecate) and replace with PARAM, or at least document what is goigh on!

--> See TODO.txt

Expand All @@ -22,6 +24,7 @@ Check:

0.5.0 (unreleased)
=====
- Cleaned up unit test output. [#102](https://github.com/tzaeschke/ode4j/pull/102)
- Fix maven warnings of type "Use Import/Export Package directive -split-package [...]"
[#101](https://github.com/tzaeschke/ode4j/pull/101)
- Port updates until 0.16.3. [#100](https://github.com/tzaeschke/ode4j/pull/100)
Expand Down
13 changes: 8 additions & 5 deletions core/src/main/java/org/ode4j/ode/internal/DLCP.java
Original file line number Diff line number Diff line change
Expand Up @@ -1381,9 +1381,8 @@ static int EstimateTestSolveLCPMemoryReq(int n)
return -1;
}

//TODO API?
//extern "C" ODE_API
public static int dTestSolveLCP()
public static int dTestSolveLCP(boolean print)
{
final int n = 100;

Expand All @@ -1409,7 +1408,9 @@ public static int dTestSolveLCP()
} else {
tol = 1e-4f;
}
System.out.println ("dTestSolveLCP()");
if (print) {
System.out.println("dTestSolveLCP()");
}

// double[] A = new double[n*nskip];//ALLOCA (dReal,A,n*nskip*sizeof(dReal));
// double[] x = new double[n];//ALLOCA (dReal,x,n*sizeof(dReal));
Expand Down Expand Up @@ -1540,8 +1541,10 @@ else if (xi >= lo[i] && xi <= hi[i] && wi == 0) {
}

// pacifier
printf ("passed: NL=%3d NH=%3d C=%3d ",n1,n2,n3);
printf ("time=%10.3f ms avg=%10.4f\n",time * 1000.0,average);
if (print) {
printf("passed: NL=%3d NH=%3d C=%3d ", n1, n2, n3);
printf("time=%10.3f ms avg=%10.4f\n", time * 1000.0, average);
}
}
arena.END_STATE_SAVE(saveInner);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,7 @@ public void dTestDataStructures()
for (i=0; i<NUM; i++) body[i] = null;
for (i=0; i<NUM; i++) joint[i] = null;

//DO(
printf ("creating world\n");
DO_printf ("creating world\n");
DxWorld w = DxWorld.dWorldCreate();
checkWorld (w);

Expand Down
2 changes: 1 addition & 1 deletion demo-cpp/src/main/java/org/ode4j/democpp/DemoI.java
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ private void demo(String[] args) {
//fn.setPathToTextures(DrawStuff.DRAWSTUFF_TEXTURE_PATH);

dInitODE2(0);
dRandSetSeed (System.currentTimeMillis());
dRandSetSeed (0); // System.currentTimeMillis());
reset_test();

// run simulation
Expand Down
2 changes: 1 addition & 1 deletion demo-cpp/src/main/java/org/ode4j/democpp/DemoOde.java
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,7 @@ private int runAllTests()
testQuaternionMultiply();
testRotationFunctions();
dTestMatrixComparison();
DLCP.dTestSolveLCP();
DLCP.dTestSolveLCP(true);
//OdeImpl.dTestDataStructures();
dCloseODE();
return 0;
Expand Down
4 changes: 2 additions & 2 deletions demo-cpp/src/main/java/org/ode4j/democpp/DemoStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
* version, for various systems. currently you have to define COMPARE_METHODS
* in step.cpp for this to work properly.
*
* @@@ report MAX error
* report MAX error
*/
class DemoStep extends dsFunctions {

Expand Down Expand Up @@ -214,7 +214,7 @@ private void demo(String[] args) {

dInitODE2(0);
//dRandSetSeed (time(null).seconds);
dRandSetSeed (System.currentTimeMillis()/1000);
dRandSetSeed (0 ); // System.currentTimeMillis()/1000);
createTest();

// run simulation
Expand Down
13 changes: 6 additions & 7 deletions demo-cpp/src/test/java/org/ode4j/tests/PRGetInfo1_Fixture_2.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@ public static void DESTRUCTOR() {
dJointSetPRParam(jId, dParamVel, (7.0) );
CHECK_EQUAL((7.0), joint.limotP.vel);

// TODO ? TZ: Probably not,
//#ifdef D_PARAM_NAMES.dParamFudgeFactor1
// if (D_PARAM_NAMES.dParamFudgeFactor1) {
System.err.println("FIXME: test_SetPRParam()");
//TODO dJointSetPRParam(jId, D_PARAM_NAMES.dParamFudgeFactor1, (5.5) );
//TODO CHECK_EQUAL((5.5), joint.limotP.get(D_PARAM_NAMES.dParamFudgeFactor));
// dJointSetPRParam(jId, D_PARAM_NAMES.dParamFudgeFactor1, (5.5) );
// CHECK_EQUAL((5.5), joint.limotP.get(D_PARAM_NAMES.dParamFudgeFactor));
// } //#endif //TZ unnecessary

dJointSetPRParam(jId, dParamCFM2, (9.0) );
Expand All @@ -251,11 +251,10 @@ public static void DESTRUCTOR() {
dJointGetPRParam(jId, dParamVel) );

//#ifdef D_PARAM_NAMES.dParamFudgeFactor1 //TZ unnecessary
System.err.println("FIXME: test_GetPRParam()");
//TODO joint.limotP.set(D_PARAM_NAMES.dParamFudgeFactor, 5.5) ;//) = (5.5);
// joint.limotP.set(D_PARAM_NAMES.dParamFudgeFactor, 5.5) ;//) = (5.5);

//TODO CHECK_EQUAL(joint.limotP.get(D_PARAM_NAMES.dParamFudgeFactor),
//TODO dJointGetPRParam(jId, D_PARAM_NAMES.dParamFudgeFactor1) );
// CHECK_EQUAL(joint.limotP.get(D_PARAM_NAMES.dParamFudgeFactor),
// dJointGetPRParam(jId, D_PARAM_NAMES.dParamFudgeFactor1) );
//#endif

joint.limotR.normal_cfm = (9.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void call(Object data, DGeom o1, DGeom o2) {
}

DContact contact = contacts.get(0);
System.out.println(contact.geom.normal);
// System.out.println(contact.geom.normal);
assertTrue(Math.abs(contact.geom.normal.get0()) < 0.01);
assertTrue(Math.abs(contact.geom.normal.get1()) < 0.01);
assertTrue(Math.abs(contact.geom.normal.get2()) > 0.99);
Expand Down
4 changes: 2 additions & 2 deletions demo-cpp/src/test/java/org/ode4j/tests/libccd/TestBoxBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public void boxboxSeparate()
ccd_vec3_t sep = new ccd_vec3_t(), expsep = new ccd_vec3_t();
ccd_vec3_t expsep2 = new ccd_vec3_t(), axis = new ccd_vec3_t();

fprintf(stderr, "\n\n\n---- boxboxSeparate ----\n\n\n");
// fprintf(stderr, "\n\n\n---- boxboxSeparate ----\n\n\n");

box1.x = box1.y = box1.z = 1.;
box2.x = 0.5;
Expand Down Expand Up @@ -391,7 +391,7 @@ public void boxboxPenetration()
RefDouble depth = new RefDouble();
ccd_vec3_t dir = new ccd_vec3_t(), pos = new ccd_vec3_t();

fprintf(stderr, "\n\n\n---- boxboxPenetration ----\n\n\n");
// fprintf(stderr, "\n\n\n---- boxboxPenetration ----\n\n\n");

box1.x = box1.y = box1.z = 1.;
box2.x = 0.5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void cylcylPenetrationEPA()
RefDouble depth = new RefDouble();
ccd_vec3_t dir = new ccd_vec3_t(), pos = new ccd_vec3_t();

fprintf(stderr, "\n\n\n---- cylcylPenetration ----\n\n\n");
// fprintf(stderr, "\n\n\n---- cylcylPenetration ----\n\n\n");

cyl1.radius = 0.35;
cyl1.height = 0.5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public void mprBoxboxSeparate()
ccd_vec3_t sep = new ccd_vec3_t(), expsep = new ccd_vec3_t();
ccd_vec3_t expsep2 = new ccd_vec3_t(), axis = new ccd_vec3_t();

fprintf(stderr, "\n\n\n---- boxboxSeparate ----\n\n\n");
// fprintf(stderr, "\n\n\n---- boxboxSeparate ----\n\n\n");

box1.x = box1.y = box1.z = 1.;
box2.x = 0.5;
Expand Down Expand Up @@ -398,7 +398,7 @@ public void mprBoxboxPenetration()
RefDouble depth = new RefDouble();
ccd_vec3_t dir = new ccd_vec3_t(), pos = new ccd_vec3_t();

fprintf(stderr, "\n\n\n---- boxboxPenetration ----\n\n\n");
// fprintf(stderr, "\n\n\n---- boxboxPenetration ----\n\n\n");

box1.x = box1.y = box1.z = 1.;
box2.x = 0.5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void mprCylcylPenetration()
RefDouble depth = new RefDouble();
ccd_vec3_t dir = new ccd_vec3_t(), pos = new ccd_vec3_t();

fprintf(stderr, "\n\n\n---- mprCylcylPenetration ----\n\n\n");
// fprintf(stderr, "\n\n\n---- mprCylcylPenetration ----\n\n\n");

cyl1.radius = 0.35;
cyl1.height = 0.5;
Expand Down
35 changes: 23 additions & 12 deletions demo-cpp/src/test/java/org/ode4j/tests/libccd/TestPolytope.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,37 @@
import static org.ode4j.ode.internal.libccd.CCDVec3.*;

public class TestPolytope {

private void DBG(String format, Object a1) {
fprintf(stderr, "%s :: " + format+ "\n", "fn", a1);//__func__, ## __VA_ARGS__);
fflush(stderr);


private static final boolean DEBUG = false;

private void DBG(String format, Object a1) {
if (DEBUG) {
fprintf(stderr, "%s :: " + format + "\n", "fn", a1);//__func__, ## __VA_ARGS__);
fflush(stderr);
}
}

private void DBG(String format, Object a1, Object a2) {
fprintf(stderr, "%s :: " + format+ "\n", "fn", a1, a2);//__func__, ## __VA_ARGS__);
fflush(stderr);
private void DBG(String format, Object a1, Object a2) {
if (DEBUG) {
fprintf(stderr, "%s :: " + format + "\n", "fn", a1, a2);//__func__, ## __VA_ARGS__);
fflush(stderr);
}
}

private void DBG2(String str) {
fprintf(stderr, "%s :: " + str + "\n", "fn");//, __func__);
fflush(stderr);
if (DEBUG) {
fprintf(stderr, "%s :: " + str + "\n", "fn");//, __func__);
fflush(stderr);
}
}

private void DBG_VEC3(ccd_vec3_t vec, String prefix) {
fprintf(stderr, "%s :: %s[%f %f %f]\n", "fn",// __func__,
prefix, ccdVec3X(vec), ccdVec3Y(vec), ccdVec3Z(vec));
fflush(stderr);
if (DEBUG) {
fprintf(stderr, "%s :: %s[%f %f %f]\n", "fn",// __func__,
prefix, ccdVec3X(vec), ccdVec3Y(vec), ccdVec3Z(vec));
fflush(stderr);
}
}


Expand Down
2 changes: 1 addition & 1 deletion demo/src/main/java/org/ode4j/demo/DemoI.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public static void main(String[] args) {

private void demo(String[] args) {
OdeHelper.initODE2(0);
dRandSetSeed (System.currentTimeMillis());
dRandSetSeed (0); // System.currentTimeMillis());
reset_test();

// run simulation
Expand Down
2 changes: 1 addition & 1 deletion demo/src/main/java/org/ode4j/demo/DemoOde.java
Original file line number Diff line number Diff line change
Expand Up @@ -1544,7 +1544,7 @@ private int runAllTests()
testQuaternionMultiply();
testRotationFunctions();
dTestMatrixComparison();
DLCP.dTestSolveLCP();
DLCP.dTestSolveLCP(true);
//OdeImpl.dTestDataStructures();
OdeHelper.closeODE();
return 0;
Expand Down
4 changes: 2 additions & 2 deletions demo/src/main/java/org/ode4j/demo/DemoStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
* version, for various systems. currently you have to define COMPARE_METHODS
* in step.cpp for this to work properly.
*
* @@@ report MAX error
* report MAX error
*/
class DemoStep extends dsFunctions {

Expand Down Expand Up @@ -174,7 +174,7 @@ public static void main(String[] args) {

private void demo(String[] args) {
OdeHelper.initODE2(0);
dRandSetSeed (System.currentTimeMillis()/1000);
dRandSetSeed (0); // System.currentTimeMillis()/1000);
createTest();

// run simulation
Expand Down
23 changes: 18 additions & 5 deletions demo/src/test/java/org/ode4j/tests/DemoCollisionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
*/
public class DemoCollisionTest {

private static final boolean PRINT = false;

//****************************************************************************
// test infrastructure, including constants and macros
Expand Down Expand Up @@ -1211,7 +1212,10 @@ private void do_test(int number, String function) {
// second batch is run.
for (int batch = 0; batch < 2; batch++) {
int reps = (batch == 0) ? TEST_REPS1 : TEST_REPS2;
System.out.println("testing " + number + " " + function + " batch " + (batch + 1) + " (" + reps + " reps)...");
if (PRINT) {
System.out.println(
"testing " + number + " " + function + " batch " + (batch + 1) + " (" + reps + " reps)...");
}

// run tests
for (int j = 0; j < reps; j++) {
Expand All @@ -1231,7 +1235,10 @@ private void do_test_partial(int number, String function, double max_failure_rat
for (int batch = 0; batch < 2; batch++) {
int reps = (batch == 0) ? TEST_REPS1 : TEST_REPS2;
total_reps += reps;
System.out.println("testing " + number + " " + function + " batch " + (batch + 1) + " (" + reps + " reps)...");
if (PRINT) {
System.out.println(
"testing " + number + " " + function + " batch " + (batch + 1) + " (" + reps + " reps)...");
}

// run tests
for (int j = 0; j < reps; j++) {
Expand All @@ -1247,13 +1254,19 @@ private void do_test_partial(int number, String function, double max_failure_rat
}

// print results
System.out.printf("%3d: %-30s: ", number, function);
if (PRINT) {
System.out.printf("%3d: %-30s: ", number, function);
}
if (failcount > 0) {
double failure_ratio = (double) failcount / (double) total_reps;
System.out.printf("FAILED (%.2f%%) at line %s\n", failure_ratio * 100.0, last_failed_line);
if (PRINT) {
System.out.printf("FAILED (%.2f%%) at line %s\n", failure_ratio * 100.0, last_failed_line);
}
assertTrue(failure_ratio < max_failure_ratio);
} else {
System.out.println("ok");
if (PRINT) {
System.out.println("ok");
}
}
}

Expand Down
27 changes: 21 additions & 6 deletions demo/src/test/java/org/ode4j/tests/DemoJointsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
//@RunWith(Parameterized.class)
public class DemoJointsTest {

private static final boolean PRINT = false;

//// some constants
//#define NUM_JOINTS 10 // number of joints to test (the `xx' value)
//#define SIDE (0.5f) // side length of a box - don't change this
Expand Down Expand Up @@ -136,6 +138,18 @@ private double cmpIdentity(final DMatrix3C A) {
return dMaxDifference(A, I);
}

private static void print(String s) {
if (PRINT) {
System.out.print(s);
}
}

private static void println(String s) {
if (PRINT) {
System.out.println(s);
}
}

//****************************************************************************
// test world construction and utilities
private void constructWorldForTest(double gravity, int bodycount,
Expand Down Expand Up @@ -1042,12 +1056,13 @@ private void doTest(int n) {
S = null;

// print results
System.out.print("test " + n + ": ");
if (max_error == dInfinity) System.out.println("error not computed");
else {
System.out.print("max scaled error = " + max_error);
if (max_error < 1) System.out.println(" - passed");
else System.out.println(" - FAILED\n");
print("test " + n + ": ");
if (max_error == dInfinity) {
println("error not computed");
} else {
print("max scaled error = " + max_error);
if (max_error < 1) println(" - passed");
else println(" - FAILED\n");
Assert.assertTrue(max_error < 1);
}
}
Expand Down
Loading