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:
expression The expression to evaluate
message The text message associated with the expression
function function name
file filename
line line 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:
expression the expression to evaluate
expr_string the expression to evaluate as a string
function function name
file filename
line line 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:
first The first value in the comparison
first_string The first value as a string
second The second value in the comparison
second_string The second value as a string
function function name
file filename
line line 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:
first The first value in the comparison
first_string The first value as a string
second The second value in the comparison
second_string The second value as a string
function function name
file filename
line line 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:
first The first value in the comparison
first_string The first value as a string
second The second value in the comparison
second_string The second value as a string
tolerance A non-negative tolerance
tolerance_string The tolerance as a string
function function name
file filename
line line 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:
first The first value in the comparison
first_string The first value as a string
second The second value in the comparison
second_string The second value as a string
tolerance A non-negative tolerance
tolerance_string The tolerance as a string
function function name
file filename
line line 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:
file filename
Note:
This function should be called only by using the macro TEST_INIT

Definition at line 290 of file test.c.

References error_init.

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

Perform the final checks and return the number of errors.

Parameters:
function function name
file filename
line line 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 error_init, 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_tags array of expected product tags
n_prod number of products
main_product the only product which should contain QC parameters
qc array of expected QC parameters
n_qc number of QC parameters

Definition at line 428 of file test.c.

References assure, and cleanup.

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().


Generated on Fri Mar 4 09:46:01 2011 for FORS Pipeline Reference Manual by  doxygen 1.4.7