-
Notifications
You must be signed in to change notification settings - Fork 1
/
testgen.h
68 lines (58 loc) · 2.25 KB
/
testgen.h
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include "testdata.h"
#include "swephexp.h"
// --- An ephemeris test data generator, configurable with a fixture file
// Test type
static const int SWISS_CALC_TEST = 1;
static const int END_OF_RANGE = -10; // negative numbers above this limit may occurs in the range
// --- Ranges (collection of single values and intervals)
typedef struct {
AS_BOOL between; // Interval or single value
int low;
int high;
} range;
#define MAXRANGE 50
typedef struct {
int size;
range line[MAXRANGE];
} rangetab;
typedef struct {
rangetab *r;
int i; // line count
int j; // interval count
} range_iterator;
static int get_next( range_iterator *iter);
// Function how to generate a series of dates (random or fixed-increment)
typedef void(*datefun)(double dates[], int n, double jd_from, double jd_to, double incr);
// --- Test data, as read from a fixture
#define MAX_FIXNUM 1000
typedef struct {
char description[100];
int planet;
int iflag;
int precisions[6];
double jd_from, jd_to, incr;
int n_dates;
datefun method;
rangetab planets;
rangetab flags;
} testFixture;
static int generateTestsetFromFixture(char* fixtureFile,char* dataFile);
static long int doGeneralHeader( FILE* out, int type, char* description );
static void doSwissCalcHeader( FILE* out, long int pos, testFixture* test, int numberOfRecords);
static int doSwissCalcTestData( FILE* out, testFixture* test, bool warn_on_flag_change);
static void warn_if_flag_changed(const swissCalcData *scData);
static int parseFixtureFile(char* fixtureFile, testFixture*, int*);
static void clear( testFixture* data );
static int parseNameValuePair( char* name, char* value, testFixture* data);
static int generateTest( FILE* out, testFixture* data);
static int parseDates( char* value, testFixture* data);
static int parsePrecisions( char* value, int* precisions );
static int parseRange( char* value, rangetab *r);
static inline int equals( char* act, char* exp) { return ! strcmp( act, exp ); }
static inline char* trim(char *s) { for (char* p = s + strlen(s)-1; *p == ' '; p-- ) *p='\0'; return s; }
static FILE* openFileBinary( const char* file );
static void doInitializations();
static char* int_to_binary(char* b, int x);