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

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

References irplib_sprintf(), and irplib_test_nfail.

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

References irplib_sprintf(), and 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 141 of file irplib_test.c.

References irplib_sprintf(), and 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 172 of file irplib_test.c.

References irplib_sprintf(), and 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 210 of file irplib_test.c.

References irplib_sprintf(), and 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 247 of file irplib_test.c.

References irplib_sprintf(), and 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 292 of file irplib_test.c.

References irplib_reset().

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

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


Variable Documentation

unsigned long irplib_test_nfail = 0 [static]
 

The number of failures

Definition at line 52 of file irplib_test.c.

Referenced by irplib_test_end_macro(), and test().


Generated on Tue Jun 19 14:39:22 2007 for UVES Pipeline Reference Manual by  doxygen 1.4.6