/[ascend]/trunk/models/johnpye/fprops/test.h
ViewVC logotype

Annotation of /trunk/models/johnpye/fprops/test.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1886 - (hide annotations) (download) (as text)
Fri Sep 19 07:22:54 2008 UTC (15 years, 10 months ago) by jpye
File MIME type: text/x-chdr
File size: 1142 byte(s)
Adding separate file with basic test routine.
1 jpye 1886 #ifndef HELMHOLTZ_TEST_H
2     #define HELMHOLTZ_TEST_H
3    
4     #include "helmholtz.h"
5    
6     /* Macros and type declarations for running simple test cases */
7    
8     typedef struct{double T,p,rho,u,h,s,cv,cp,cp0,a;} TestData;
9    
10     /**
11     Run tests for p, u, h, s, a against values from a user-provided TestData array
12     Tolerances are specified in the cdoe, in test.c.
13    
14     @return 1 if any failures occurred.
15     */
16     int helm_run_test_cases(const HelmholtzData *d, unsigned ntd, const TestData *td);
17    
18     /* a simple macro to actually do the testing */
19     #define ASSERT_TOL(FN,PARAM1,PARAM2,PARAM3,VAL,TOL) {\
20     double cval; cval = FN(PARAM1,PARAM2,PARAM3);\
21     double err; err = cval - (double)(VAL);\
22     double relerrpc = (cval-(VAL))/(VAL)*100;\
23     if(fabs(relerrpc)>maxerr)maxerr=fabs(relerrpc);\
24     if(fabs(err)>fabs(TOL)){\
25     fprintf(stderr,"ERROR in line %d: value of '%s(%f,%f,%s)' = %f,"\
26     " should be %f, error is %f (%.2f%%)!\n"\
27     , __LINE__, #FN,PARAM1,PARAM2,#PARAM3, cval, VAL,cval-(VAL)\
28     ,relerrpc\
29     );\
30     exit(1);\
31     }else{\
32     fprintf(stderr," OK, %s(%f,%f,%s) = %8.2e with %.6f%% err.\n"\
33     ,#FN,PARAM1,PARAM2,#PARAM3,VAL,relerrpc\
34     );\
35     }\
36     }
37    
38     #endif

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22