Lattice generator tests.

... there are bugs to be fixed


Former-commit-id: 2437fc3c1dd76ba5bbe83d082b036758c5ba8ba7
This commit is contained in:
Marek Nečada 2018-11-29 15:59:45 +02:00
parent a300ac9e0f
commit 6b88106cce
2 changed files with 39 additions and 1 deletions

View File

@ -106,7 +106,7 @@ typedef struct PGenSphClassInfo { // static PGenSph info
// TOP DATA STRUCTURE DEFINITION HERE
typedef struct PGenSph {
const PGenSphClassInfo * const c;
const PGenSphClassInfo * /*const*/ c;
void *stateData; // shall be NULL if invalid (destroyed)
} PGenSph;

38
tests/test_latticegens.c Normal file
View File

@ -0,0 +1,38 @@
//c99 -o test_latticegens -ggdb -Wall -I ../ test_latticegens.c ../qpms/latticegens.c -lm
#include <qpms/lattices.h>
#include <stdio.h>
void print_PGenSphReturnData(PGenSphReturnData d) {
sph_t s = d.point_sph;
cart3_t c = sph2cart(s);
printf("sph: (%g, %g π, %g π), cart: (%g, %g, %g), flags: %#xd\n",
s.r, s.theta / M_PI, s.phi / M_PI, c.x, c.y, c.z, d.flags);
}
void dump_PGenSph(PGenSph *g) {
PGenSphReturnData d;
do {
d = PGenSph_next(g);
print_PGenSphReturnData(d);
} while (d.flags & PGEN_NOTDONE);
}
#define DO_AND_PRINT(label, s) printf(#label ":\n" #s "\n"); s ;
int main(int argc, char **argv) {
PGenSph g;
DO_AND_PRINT(test1a, g = PGenSph_zAxis_new_minMaxR(0.2, 0.14, 5, true, 7, true, PGENSPH_ZAXIS_INC_FROM_ORIGIN))
dump_PGenSph(&g);
DO_AND_PRINT(test1b, g = PGenSph_zAxis_new_minMaxR(0.2, 0.14, 5, true, 7, true, PGENSPH_ZAXIS_INC_TOWARDS_ORIGIN))
dump_PGenSph(&g);
DO_AND_PRINT(test2a, g = PGenSph_zAxis_new_minMaxR(0.2, 0.05, 5.05, true, 7.05, true, PGENSPH_ZAXIS_INC_FROM_ORIGIN))
dump_PGenSph(&g);
DO_AND_PRINT(test2b, g = PGenSph_zAxis_new_minMaxR(0.2, 0.05, 5.05, true, 7.05, true, PGENSPH_ZAXIS_INC_TOWARDS_ORIGIN))
dump_PGenSph(&g);
DO_AND_PRINT(test3a, g = PGenSph_zAxis_new_minMaxR(0.2, 0.05, 5.05, false, 7.05, false, PGENSPH_ZAXIS_INC_FROM_ORIGIN))
dump_PGenSph(&g);
DO_AND_PRINT(test3b, g = PGenSph_zAxis_new_minMaxR(0.2, 0.05, 5.05, false, 7.05, false, PGENSPH_ZAXIS_INC_TOWARDS_ORIGIN))
dump_PGenSph(&g);
}