FORS Pipeline Reference Manual 4.9.9
Defines | Functions | Variables
Unit test infrastructure

Defines

#define cleanup

Functions

static void _test (int expression, const char *message, const char *function, const char *file, unsigned line)
 Evaluate an expression and update an internal counter if it fails.
void test_macro (int expression, const char *expr_string, const char *function, const char *file, unsigned line)
 Test a given expression.
void test_eq_macro (int first, const char *first_string, int second, const char *second_string, const char *function, const char *file, unsigned line)
 Test if two integer expressions are equal.
void test_eq_string_macro (const char *first, const char *first_string, const char *second, const char *second_string, const char *function, const char *file, unsigned line)
 Test if two strings are equal.
void test_abs_macro (double first, const char *first_string, double second, const char *second_string, double tolerance, const char *tolerance_string, const char *function, const char *file, unsigned line)
 Test if two numerical expressions are within a given (absolute) tolerance.
void test_rel_macro (double first, const char *first_string, double second, const char *second_string, double tolerance, const char *tolerance_string, const char *function, const char *file, unsigned line)
 Test if two numerical expressions are within a given relative tolerance.
void test_init_macro (const char *file)
 Initialize CPL + messaging.
unsigned test_end_macro (const char *function, const char *file, unsigned line)
 Perform the final checks and return the number of errors.
void test_recipe_output (const cpl_frameset *frames, const char *const product_tags[], int n_prod, const char *main_product, const char *const qc[], int n_qc)
 Test existence of recipe products.

Variables

static unsigned long test_nfail = 0
static cpl_errorstate error_init

Define Documentation

#define cleanup
Value:
do { \
    cpl_propertylist_delete(product_header); \
} while(0)

Definition at line 412 of file test.c.


Function Documentation

static void _test ( int  expression,
const char *  message,
const char *  function,
const char *  file,
unsigned  line 
) [static]

Evaluate an expression and update an internal counter if it fails.

Parameters:
expressionThe expression to evaluate
messageThe text message associated with the expression
functionfunction name
filefilename
lineline number

Definition at line 63 of file test.c.

References test_nfail.

Referenced by test_abs_macro(), test_eq_macro(), test_eq_string_macro(), test_macro(), and test_rel_macro().

void test_macro ( int  expression,
const char *  expr_string,
const char *  function,
const char *  file,
unsigned  line 
)

Test a given expression.

Parameters:
expressionthe expression to evaluate
expr_stringthe expression to evaluate as a string
functionfunction name
filefilename
lineline number
Note:
A zero value of the expression is a failure, other values are not

Definition at line 112 of file test.c.

References _test().

Referenced by test_end_macro().

void test_eq_macro ( int  first,
const char *  first_string,
int  second,
const char *  second_string,
const char *  function,
const char *  file,
unsigned  line 
)

Test if two integer expressions are equal.

Parameters:
firstThe first value in the comparison
first_stringThe first value as a string
secondThe second value in the comparison
second_stringThe second value as a string
functionfunction name
filefilename
lineline number
Note:
This function should only be called from the macro TEST_ABS

Definition at line 139 of file test.c.

References _test().

Referenced by test_end_macro().

void test_eq_string_macro ( const char *  first,
const char *  first_string,
const char *  second,
const char *  second_string,
const char *  function,
const char *  file,
unsigned  line 
)

Test if two strings are equal.

Parameters:
firstThe first value in the comparison
first_stringThe first value as a string
secondThe second value in the comparison
second_stringThe second value as a string
functionfunction name
filefilename
lineline number
Note:
This function should only be called from the macro TEST_ABS

Definition at line 170 of file test.c.

References _test().

void test_abs_macro ( double  first,
const char *  first_string,
double  second,
const char *  second_string,
double  tolerance,
const char *  tolerance_string,
const char *  function,
const char *  file,
unsigned  line 
)

Test if two numerical expressions are within a given (absolute) tolerance.

Parameters:
firstThe first value in the comparison
first_stringThe first value as a string
secondThe second value in the comparison
second_stringThe second value as a string
toleranceA non-negative tolerance
tolerance_stringThe tolerance as a string
functionfunction name
filefilename
lineline number
Note:
This function should only be called from the macro TEST_ABS

Definition at line 208 of file test.c.

References _test().

void test_rel_macro ( double  first,
const char *  first_string,
double  second,
const char *  second_string,
double  tolerance,
const char *  tolerance_string,
const char *  function,
const char *  file,
unsigned  line 
)

Test if two numerical expressions are within a given relative tolerance.

Parameters:
firstThe first value in the comparison
first_stringThe first value as a string
secondThe second value in the comparison
second_stringThe second value as a string
toleranceA non-negative tolerance
tolerance_stringThe tolerance as a string
functionfunction name
filefilename
lineline number
Note:
This function should only be called from the macro TEST_REL

Definition at line 245 of file test.c.

References _test().

void test_init_macro ( const char *  file)

Initialize CPL + messaging.

Parameters:
filefilename
Note:
This function should be called only by using the macro TEST_INIT

Definition at line 290 of file test.c.

unsigned test_end_macro ( const char *  function,
const char *  file,
unsigned  line 
)

Perform the final checks and return the number of errors.

Parameters:
functionfunction name
filefilename
lineline number
Returns:
The total number of errors in the tested module
Note:
This function should only be called from the macro TEST_END

Definition at line 381 of file test.c.

References test_eq_macro(), test_macro(), and test_nfail.

void test_recipe_output ( const cpl_frameset *  frames,
const char *const  product_tags[],
int  n_prod,
const char *  main_product,
const char *const  qc[],
int  n_qc 
)

Test existence of recipe products.

Parameters:
product_tagsarray of expected product tags
n_prodnumber of products
main_productthe only product which should contain QC parameters
qcarray of expected QC parameters
n_qcnumber of QC parameters

Definition at line 428 of file test.c.

References assure.

Referenced by test_bias(), test_img_science(), test_img_screen_flat(), test_img_sky_flat(), and test_zeropoint().


Variable Documentation

unsigned long test_nfail = 0 [static]

The number of failures

Definition at line 49 of file test.c.

Referenced by _test(), and test_end_macro().