From 4e7aadf540136409407637dbbf2492525de65eba Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Tue, 31 Mar 2020 18:57:22 +0200 Subject: [PATCH] added tests for bt::normalized_at, and some old tests for distances --- binary-tiling.cpp | 2 ++ devmods/tests.cpp | 82 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 devmods/tests.cpp diff --git a/binary-tiling.cpp b/binary-tiling.cpp index dc83f0c3..8ea815e9 100644 --- a/binary-tiling.cpp +++ b/binary-tiling.cpp @@ -654,6 +654,8 @@ EX namespace bt { * * Otherwise: just return h * + * See also: in devmods/tests.cpp, -bt-test tests whether this works correctly + * */ EX transmatrix normalized_at(hyperpoint h) { diff --git a/devmods/tests.cpp b/devmods/tests.cpp new file mode 100644 index 00000000..4c05b5e3 --- /dev/null +++ b/devmods/tests.cpp @@ -0,0 +1,82 @@ +#include "../hyper.h" +#include +#include + +namespace hr { + +namespace tests { + +int readArgs() { + using namespace arg; + + if(0) ; + else if(argis("-test-dist")) { + start_game(); + shift(); int d = argi(); + vector l = currentmap->allcells(); + int errors = 0; + int unknown = 0; + for(cell *c1: l) if(c1->cpdist <= d) + for(cell *c2: l) if(c2->cpdist <= d) { + int cd = celldistance(c1, c2); + int bcd = bounded_celldistance(c1, c2); + if(bcd == DISTANCE_UNKNOWN) + unknown++; + else if(cd != bcd) { + errors++; + println(hlog, "distance error: ", tie(c1,c2), " cd = ", cd, " bcd = ", bcd); + } + } + + int q = 0; + for(cell *c: l) if(c->cpdist <= d) q++; + + println(hlog, "cells checked: ", q, " errors: ", errors, " unknown: ", unknown, " in: ", full_geometry_name()); + + if(errors) exit(1); + } + else if(argis("-test-bt")) { + PHASEFROM(3); + for(int i=0; i Euler characteristic -2 +// octagon: -2/6 +// ~> 6 octagons + +} +}