Enumerations | |
enum | lub_test_status_t { LUB_TEST_PASS, LUB_TEST_FAIL } |
enum | lub_test_verbosity_t { LUB_TEST_TERSE = 0, LUB_TEST_NORMAL, LUB_TEST_VERBOSE } |
Functions | |
void | lub_test_parse_command_line (int argc, const char *const *argv) |
void | lub_test_begin (const char *fmt,...) |
void | lub_test_log (lub_test_verbosity_t level, const char *fmt,...) |
lub_test_status_t | lub_test_get_status (void) |
int | lub_test_failure_count (void) |
void | lub_test_end (void) |
void | lub_test_stop_here (void) |
void | lub_test_seq_begin (int seq, const char *fmt,...) |
void | lub_test_seq_log (lub_test_verbosity_t level, const char *fmt,...) |
void | lub_test_seq_end (void) |
lub_test_status_t | lub_test_check (bool_t expr, const char *fmt,...) |
lub_test_status_t | lub_test_check_int (int expect, int actual, const char *fmt,...) |
lub_test_status_t | lag_test_test_float (double min, double max, double actual, const char *fmt,...) |
All output has an associated Verbosity level, and will only be output if the current Verbosity setting is equal to or greater than that level.
Sequences are begun with a function call specifying their sequence number and a printf-style format specification of their name. This outputs a sequence header (at 'normal' verbosity) and resets the test counter. Another call ends the sequence.
At the Terse verbosity level, only failing tests generate log output.
Test functions are provided for testing:
Note that it is not required to use any logging function; the Utilities will generate a reasonable log based on the sequence and test calls. However, additional logging may add significant value and human readability to the test results.
Last Revised 03-Oct-2002 (BBB)
enum lub_test_status_t |
enum lub_test_verbosity_t |
lub_test_status_t lag_test_test_float | ( | double | min, | |
double | max, | |||
double | actual, | |||
const char * | fmt, | |||
... | ||||
) |
This function is designed to ensure that a floating point value is within acceptible limits. It takes a minimum, maximum and actual value. The test passes if the actual value is greater or equal than the minimum, and less than or equal to the maximum. All three values are recorded in the log output.
min | the minimum acceptible value |
max | the maximum acceptible value |
actual | the actual value |
fmt | a printf style format string to specify the test scenario |
void lub_test_begin | ( | const char * | fmt, | |
... | ||||
) |
This starts and specifies the name for the unit-test.
fmt | a printf style format string to specify the name of the test |
lub_test_status_t lub_test_check | ( | bool_t | expr, | |
const char * | fmt, | |||
... | ||||
) |
The most basic test function, this simply evaluates an expression for BOOL_TRUE/BOOL_FALSE and passes/fails as a result. Like all test functions it accepts a printf-style format and parameters to describe the test.
expr | a boolean expression to evaluate |
fmt | a printf style format string to specify the test scenario |
lub_test_status_t lub_test_check_int | ( | int | expect, | |
int | actual, | |||
const char * | fmt, | |||
... | ||||
) |
This function is almost identical to test() except it accepts an exepcted and actual value to compares them. Equal values cause the test to pass, unequal cause the test to fail. Both values are recorded in the log output making it easier to understand failures.
expect | the expected integer value |
actual | the actual integer value |
fmt | a printf style format string to specify the test scenario |
void lub_test_end | ( | void | ) |
This function ends the unit-test and closes the log file.
int lub_test_failure_count | ( | void | ) |
The test utilities maintain internal counts for all the tests that have been performed since the unittest_begin() call. This function lets a client get the number of failures so far.
lub_test_status_t lub_test_get_status | ( | void | ) |
This function provide the current overall status for the unit-test. If any tests have failed then the unit-test is deemed to have failed.
void lub_test_log | ( | lub_test_verbosity_t | level, | |
const char * | fmt, | |||
... | ||||
) |
This is the most generic of the logging functions. No addition formating is performed.
level | the verbosity level for this message |
fmt | a printf style format string to specify the message to log |
void lub_test_parse_command_line | ( | int | argc, | |
const char *const * | argv | |||
) |
This function is responsible for parsing all the command line options, setting run time variables, and opening a log file if necessary.
argc | The number of command line arguments |
argv | An array of command line arguments |
void lub_test_seq_begin | ( | int | seq, | |
const char * | fmt, | |||
... | ||||
) |
This function starts a new test sequence.
seq | a user specified sequence number |
fmt | a printf style format string to specify the sequence name |
void lub_test_seq_end | ( | void | ) |
This function marks the end of the current sequence.
void lub_test_seq_log | ( | lub_test_verbosity_t | level, | |
const char * | fmt, | |||
... | ||||
) |
This is a good general purpose logging function. It parameters are the same as unittest_log, but this will log the provided information with the current sequence number, properly indented to provide nicely formatted output within a test.
level | The verbosity level of the message |
fmt | a printf style format string to specify the message |
void lub_test_stop_here | ( | void | ) |
This function is provided as a DEBUG aid. A breakpoint set on this function will be reached everytime a test fails, with the failure case in context.