Unit test infrastructure


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 irplib_test_macro (int expression, const char *expr_string, const char *function, const char *file, unsigned line)
 Test a given expression.
void irplib_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 irplib_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 irplib_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 irplib_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 irplib_test_init_macro (const char *file)
 Initialize CPL messaging, IRPLIB.
unsigned irplib_test_end_macro (const char *function, const char *file, unsigned line)
 Perform the final checks and return the number of errors.

Variables

static unsigned long irplib_test_nfail = 0
static clock_t irplib_test_start

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 72 of file irplib_test.c.

References irplib_test_nfail.

Referenced by irplib_test_abs_macro(), irplib_test_eq_macro(), irplib_test_eq_string_macro(), irplib_test_macro(), irplib_test_rel_macro(), and table_erase_selected().

void irplib_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 121 of file irplib_test.c.

References test().

Referenced by irplib_test_end_macro().

void irplib_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 IRPLIB_TEST_ABS

Definition at line 148 of file irplib_test.c.

References test().

Referenced by irplib_test_end_macro().

void irplib_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 IRPLIB_TEST_ABS

Definition at line 179 of file irplib_test.c.

References test().

void irplib_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 IRPLIB_TEST_ABS

Definition at line 217 of file irplib_test.c.

References test().

void irplib_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 IRPLIB_TEST_REL

Definition at line 254 of file irplib_test.c.

References test().

void irplib_test_init_macro ( const char *  file  ) 

Initialize CPL messaging, IRPLIB.

Parameters:
file filename
Note:
This function should be called only by using the macro IRPLIB_TEST_INIT

Definition at line 299 of file irplib_test.c.

References irplib_reset(), and irplib_test_start.

unsigned irplib_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 IRPLIB_TEST_END

Definition at line 395 of file irplib_test.c.

References irplib_test_eq_macro(), irplib_test_macro(), irplib_test_nfail, and irplib_test_start.


Variable Documentation

unsigned long irplib_test_nfail = 0 [static]

The number of failures

Definition at line 58 of file irplib_test.c.

Referenced by irplib_test_end_macro(), and test().


Generated on Thu Nov 15 14:32:37 2007 for UVES Pipeline Reference Manual by  doxygen 1.5.1