devmods/tests:: added -test-push

This commit is contained in:
Zeno Rogue 2020-04-17 17:44:22 +02:00
parent 9050cee2fb
commit 87168241ee
1 changed files with 28 additions and 0 deletions

View File

@ -6,6 +6,20 @@ namespace hr {
namespace tests {
string test_eq(hyperpoint h1, hyperpoint h2, ld err = 1e-6) {
if(sqhypot_d(MDIM, h1 -h2) < err)
return "OK";
else
return "ERROR";
}
string test_eq(transmatrix T1, transmatrix T2, ld err = 1e-6) {
if(eqmatrix(T1, T2, err))
return "OK";
else
return "ERROR";
}
int readArgs() {
using namespace arg;
@ -68,6 +82,20 @@ int readArgs() {
println(hlog, "(but not in Arnold's cat)");
}
}
else if(argis("-test-push")) {
PHASEFROM(3);
for(eGeometry g: {gSol, gNil, gCubeTiling, gSpace534, gCell120}) {
stop_game();
set_geometry(g);
println(hlog, "testing geometry: ", geometry_name());
hyperpoint h = hyperpoint(.1, .2, .3, 1);
h = normalize(h);
println(hlog, "h = ", h);
println(hlog, "test rgpushxto0: ", test_eq(rgpushxto0(h) * C0, h));
println(hlog, "test gpushxto0: ", test_eq(gpushxto0(h) * h, C0));
println(hlog, "test inverses: ", test_eq(inverse(rgpushxto0(h)), gpushxto0(h)));
}
}
else return 1;
return 0;
}