1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
From: Ole Streicher <olebole@debian.org>
Date: Sun, 13 Oct 2019 14:45:26 +0200
Subject: Check the values returned by the test
---
ast_test.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/ast_test.c b/ast_test.c
index 61e948e..5ee56d3 100644
--- a/ast_test.c
+++ b/ast_test.c
@@ -7,6 +7,8 @@
/* C header files. */
/* --------------- */
#include <stdio.h>
+#include <math.h>
+#include <assert.h>
/* Main function. */
/* ============== */
@@ -100,8 +102,32 @@ int main( int argc, char *argv[] ) {
astTran2( cvt, 10, xin, yin, 1, xout, yout );
printf( "\n");
+ for ( i = 0; i < NCOORD; i++ ) {
+ // reference values taken from an example run on x86_64
+ double x0[NCOORD] = { 0.019746, 0.191142, 0.363160, 0.536812,
+ 0.714043, 0.898732, 1.098905, 1.332477,
+ 1.644299, 2.152969 };
+ double y0[NCOORD] = { 0.000018, 0.143869, 0.288499, 0.434597,
+ 0.582667, 0.732871, 0.884739, 1.036409,
+ 1.182151, 1.302710 };
+ assert(fabs(xout[i] - x0[i]) < 1e-5);
+ assert(fabs(yout[i] - y0[i]) < 1e-5);
+ }
+
/* Perform the inverse transformation. */
astTran2( cvt, 10, xout, yout, 0, xin, yin );
+
+ for ( i = 0; i < NCOORD; i++ ) {
+ double x0 = sin(0.1*i) * cos(0.2*i);
+ double y0 = cos(0.1*i) * cos(0.2*i);
+ double z0 = sin(0.2*i);
+ double x1 = sin(xin[i]) * cos(yin[i]);
+ double y1 = cos(xin[i]) * cos(yin[i]);
+ double z1 = sin(yin[i]);
+ assert(fabs(x0-x1) < 1e-5);
+ assert(fabs(y0-y1) < 1e-5);
+ assert(fabs(z0-z1) < 1e-5);
+ }
}
/* End the AST context. */
|