su 1.12.11devel
|
Macros for unit tests. More...
#include <sofia-sip/su_types.h>
Go to the source code of this file.
Macros | |
#define | BEGIN() |
Begin a test function. | |
#define | END() |
End a test function. | |
#define | TEST0(suite) |
Test that suite returns a nonzero value. | |
#define | TEST_1(suite) |
Test that suite returns a nonzero value. | |
#define | TEST_VOID(suite) |
Test a void suite. | |
#define | TEST(suite, expected) |
Test that suite is equal to expected. | |
#define | TEST_P(suite, expected) |
Test that suite is same pointer as expected. | |
#define | TEST64(suite, expected) |
Test that 64-bit suite is equal to expect. | |
#define | TEST_D(suite, expected) |
Test that suite is same double as expected. | |
#define | TEST_S(suite, expected) |
Test that suite is same string as expected. | |
#define | TEST_M(suite, expected, len) |
Test that suite is results as identical memory as expected. | |
#define | TEST_SIZE(suite, expected) |
Test that suite has same size as expected. | |
#define | TEST_LOG(x) |
Print in torture test with -l option. | |
Enumerations | |
enum | { tst_verbatim , tst_abort , tst_log } |
Macros for unit tests.
The macros defined here can be used by unit test programs. When a test fails, the TEST macros print the offending file name and line number. They use format that is accepted by Emacs and other fine editors so you can directly go to the source code of the failed test with next-error.
You should define the macro TSTFLAGS to a int variable possibly containing a flag tst_verbatim. As a convention, the int variable should be set when your test program is run with -v
or --verbatim
command line option. If the (TSTFLAGS & tst_verbatim) is true, the test macros log the test before executing it and the result of successful tests, too.
You should typedef longlong to integer type at least 64 bit wide before including <sofia-sip/tstdef.h>, too.
As an example, we provide a test program making sure that inet_ntop() and inet_pton() behave as expected and that we can create UDP/IPv4 sockets with su library:
#define TEST0 | ( | suite | ) |
Test that suite returns a nonzero value.