![]() |
ooc
1.3c
Object Oriented tollkit fo ANSI C
|
TestCase class - base class for unit testing. More...

Data Structures | |
| struct | TestCaseMethod |
| Test method order table. More... | |
| struct | TestCaseVtable |
| TestCase virtual functions. More... | |
Macros | |
Test method definitions. | |
Components defining test methods and execution of them. | |
| #define | TEST(name) |
| A test method order table entry. More... | |
TestCase assertions. | |
These macros can be used in the test methods and in If the assertion fails, the unit test run will report a fail message indicating the source file name and the line number in the source file. The test run will continue with the next statement. | |
| #define | fail() |
| Unconditional fail. More... | |
| #define | assertTrue(expr) |
| Fail if not TRUE. More... | |
| #define | assertFalse(expr) |
| Fail if not FALSE. More... | |
| #define | assertNull(expr) |
| Fail if not NULL. More... | |
| #define | assertNotNull(expr) |
| Fail if NULL. More... | |
| #define | assertZero(expr) |
| Fail if not 0. More... | |
| #define | assertNotZero(expr) |
| Fail if 0L. More... | |
| #define | failMsg(msg) |
| Unconditional fail with a specific message. More... | |
| #define | assertTrueMsg(expr, msg) |
| Fail if not TRUE with a specific message. More... | |
| #define | assertFalseMsg(expr, msg) |
| Fail if not FALSE with a specific message. More... | |
| #define | assertNullMsg(expr, msg) |
| Fail if not NULL with a specific message. More... | |
| #define | assertNotNullMsg(expr, msg) |
| Fail if NULL with a specific message. More... | |
| #define | assertZeroMsg(expr, msg) |
| Fail if not 0 with a specific message. More... | |
| #define | assertNotZeroMsg(expr, msg) |
| Fail if 0 with a specific message. More... | |
Functions | |
| int | testcase_run (TestCase) |
| Run the whole TestCase. More... | |
| int | testcase_run_before_class (TestCase) |
| Start the execution of a test series. More... | |
| void | testcase_run_test (TestCase, const char *, test_method_type) |
| Run a single test. More... | |
| int | testcase_run_after_class (TestCase) |
| Finishes the execution of a test series. More... | |
TestCase class - base class for unit testing.
TestCase is a base class for unit testing. All of your Unit tests inherits TestCase. The process to create a new unit test in your project:
| #define assertFalse | ( | expr | ) |
Fail if not FALSE.
Reports a failed status if not FALSE and continues.
| #define assertFalseMsg | ( | expr, | |
| msg | |||
| ) |
Fail if not FALSE with a specific message.
Reports a failed status with the message if not FALSE and continues.
char* and will not be freed. | #define assertNotNull | ( | expr | ) |
Fail if NULL.
Reports a failed status if NULL and continues.
| #define assertNotNullMsg | ( | expr, | |
| msg | |||
| ) |
Fail if NULL with a specific message.
Reports a failed status with the message if NULL and continues.
char* and will not be freed. | #define assertNotZero | ( | expr | ) |
Fail if 0L.
Reports a failed status if 0 and continues.
| #define assertNotZeroMsg | ( | expr, | |
| msg | |||
| ) |
Fail if 0 with a specific message.
Reports a failed status with the message if 0 and continues.
char* and will not be freed. | #define assertNull | ( | expr | ) |
Fail if not NULL.
Reports a failed status if not NULL and continues.
| #define assertNullMsg | ( | expr, | |
| msg | |||
| ) |
Fail if not NULL with a specific message.
Reports a failed status with the message if not NULL and continues.
char* and will not be freed. | #define assertTrue | ( | expr | ) |
Fail if not TRUE.
Reports a failed status if not TRUE and continues.
| #define assertTrueMsg | ( | expr, | |
| msg | |||
| ) |
Fail if not TRUE with a specific message.
Reports a failed status with the message if not TRUE and continues.
char* and will not be freed. | #define assertZero | ( | expr | ) |
Fail if not 0.
Reports a failed status if not 0 and continues.
| #define assertZeroMsg | ( | expr, | |
| msg | |||
| ) |
Fail if not 0 with a specific message.
Reports a failed status with the message if not 0 and continues.
char* and will not be freed. | #define fail | ( | ) |
Unconditional fail.
Reports a failed status and continues.
| #define failMsg | ( | msg | ) |
Unconditional fail with a specific message.
Reports a failed status with the message and continues.
char* and will not be freed. | #define TEST | ( | name | ) |
A test method order table entry.
This macro places a test method entry point into the test method order table. The test methods will be executed in the order they apper in the table.
| name | The name of the test method. |
| int testcase_run | ( | TestCase | self | ) |
Run the whole TestCase.
If the testcase was constructed with a method order table then this function runs all methods defined in the table.
It also runs the before_class() end after_class() methods.
This is the convenient way of running test methods and suites for the most cases.
This is equvivalent with the following pseudo code:
if( testcase_run_before_class(self) == 0)
testcase_run_all_methods(self);
return testcase_run_after_class(self);
| self | The TestCase to be run. The method order table must exist! |
| int testcase_run_after_class | ( | TestCase | self | ) |
| int testcase_run_before_class | ( | TestCase | self | ) |
| void testcase_run_test | ( | TestCase | self, |
| const char * | name, | ||
| test_method_type | method | ||
| ) |
Run a single test.
Runs a single test method with the given display name. The testcase_run_before_class() function must be called before, and testcase_run_after_class() must be called at the end.
The testcase_run_test() can be called any times between testcase_run_before_class() and testcase_run_after_class().
The before() and after() methods are called automatically.
| self | The test case |
| name | The display name of the test |
| method | The test function to invoke |