Lhaz
|
マクロ定義 | |
#define | BEGIN_TEST(x) BEGIN_TEST_FUNC(x) BEGIN_TEST_BLOCK |
#define | END_TEST END_TEST_BLOCK END_TEST_FUNC |
#define | BEGIN_TESTF(x, f) BEGIN_TEST_FUNC(x) BEGIN_FIXTURE_BLOCK(f) BEGIN_TEST_BLOCK |
#define | END_TESTF END_TEST_BLOCK END_FIXTURE_BLOCK END_TEST_FUNC |
#define | FIXTURE(x) ¥ |
#define | SETUP(x) void FIXTURE_##x::Setup() |
#define | TEARDOWN(x) void FIXTURE_##x::Teardown() |
These are the basic macros you will use for creating tests and doing setup/teardown.
#define BEGIN_TEST | ( | x | ) | BEGIN_TEST_FUNC(x) BEGIN_TEST_BLOCK |
This macro indicates the beginning of a test. It writes the first part of a function named "x" ensuring you use the proper function prototype, and that the function name is exported (thereby readable by WinUnit.exe). Additionally it includes a try, which is closed in a catch by the END_TEST macro.
#define BEGIN_TESTF | ( | x, | |
f | |||
) | BEGIN_TEST_FUNC(x) BEGIN_FIXTURE_BLOCK(f) BEGIN_TEST_BLOCK |
This macro indicates the beginning of a test that uses a fixture. It needs an extra try/catch to handle the case where Teardown (i.e. the destructor of the "fixture object") throws exceptions (see documentation for terminate() function for why this could be a problem)
#define END_TEST END_TEST_BLOCK END_TEST_FUNC |
This macro indicates the end of a test. It's necessary because it includes a catch block. Since these tests use C++ exceptions to indicate failure, and when thrown, they are crossing a DLL boundary, they end up being treated as an unhandled exception, and the stack doesn't get unwound. This results in unexpected behavior if you were counting on C++ scoping effects. The solution is to put a try/catch block around every exported function, and just do a throw in the catch block.
#define END_TESTF END_TEST_BLOCK END_FIXTURE_BLOCK END_TEST_FUNC |
This macro indicates the end of a test that uses a fixture.
#define FIXTURE | ( | x | ) | ¥ |
This macro indicates a fixture of name x.
#define SETUP | ( | x | ) | void FIXTURE_##x::Setup() |
This macro starts the setup function for fixture x. It's used like:
()
#define TEARDOWN | ( | x | ) | void FIXTURE_##x::Teardown() |
This macro starts the teardown function for fixture x. It's used like:
()