NCBI C++ ToolKit
|
Classes | |
struct | SNcbiTestUserFuncReg |
Class for implementing automatic registration of user functions. More... | |
struct | SNcbiTestRegistrar |
Extension auto-registrar from Boost.Test that can automatically set the timeout for unit. More... | |
struct | SNcbiTestTCTimeout< T > |
Copy of auto_tc_exp_fail from Boost.Test to store the value of timeout for each test. More... | |
class | CNcbiTestParamTestCaseGenerator< ParamType, ParamIter > |
Special generator of test cases for function accepting one parameter. More... | |
class | CNcbiTestMemoryCleanupList |
CNcbiTestMemoryCleanupList – Define a list of pointers to free at exit. More... | |
Macros | |
#define | NCBITEST_INIT_CMDLINE(var_name) |
Macro for introducing function initializing argument descriptions for tests. More... | |
#define | NCBITEST_AUTO_INIT() NCBITEST_AUTOREG_FUNCTION(eTestUserFuncInit) |
Macro for introducing initialization function which will be called before tests execution and only if tests will be executed (if there's no command line parameter -dryrun or –do_not_test) even if only select number of tests will be executed (if command line parameter –run_test=... More... | |
#define | NCBITEST_AUTO_FINI() NCBITEST_AUTOREG_FUNCTION(eTestUserFuncFini) |
Macro for introducing finalization function which will be called after actual tests execution even if only select number of tests will be executed (if command line parameter –run_test=... More... | |
#define | NCBITEST_INIT_VARIABLES(var_name) |
Macro for introducing function which should initialize configuration conditions parser. More... | |
#define | NCBITEST_INIT_TREE() NCBITEST_AUTOREG_FUNCTION(eTestUserFuncDeps) |
Macro for introducing function which should initialize dependencies between test units and some hard coded (not taken from configuration file) tests disablings. More... | |
#define | NCBITEST_DISABLE(test_name) NcbiTestDisable(NcbiTestGetUnit(BOOST_STRINGIZE(test_name))) |
Unconditionally disable test case. More... | |
#define | NCBITEST_DEPENDS_ON(test_name, dep_name) |
Add dependency between test test_name and dep_name. More... | |
#define | NCBITEST_DEPENDS_ON_N(test_name, N, dep_names_array) |
Add dependency between test test_name and several other tests which names given in the list dep_names_array. More... | |
#define | NCBITEST_ADD_TEST_CASE(function) |
Set of macros to manually add test cases that cannot be created using BOOST_AUTO_TEST_CASE. More... | |
#define | NCBITEST_ADD_TEST_CASE1(function, param1) |
#define | NCBITEST_ADD_TEST_CASE2(function, param1, param2) |
#define | NCBITEST_ADD_TEST_CASE3(function, param1, param2, param3) |
#define | NCBITEST_DEPENDS_ON_N_IMPL(z, n, names_array) |
Helper macro to implement NCBI_TEST_DEPENDS_ON_N. More... | |
#define | NCBITEST_AUTOREG_FUNC(type) BOOST_JOIN(BOOST_JOIN(Ncbi_, type), __LINE__) |
Helper macros for unique identifiers. More... | |
#define | NCBITEST_AUTOREG_OBJ BOOST_JOIN(NcbiTestAutoObj, __LINE__) |
#define | NCBITEST_AUTOREG_HELPER BOOST_JOIN(NcbiTestAutoHelper, __LINE__) |
#define | NCBITEST_AUTOREG_FUNCTION(type) |
#define | NCBITEST_AUTOREG_PARAMFUNC(type, param_decl, param_func) |
Typedefs | |
typedef void(* | TNcbiTestUserFunction) (void) |
Type of user-defined function which will be automatically registered in test framework. More... | |
typedef boost::unit_test::ut_detail::auto_test_unit_registrar | SNcbiTestRegistrar::TParent |
typedef boost::unit_test::callback1< ParamType > | CNcbiTestParamTestCaseGenerator< ParamType, ParamIter >::TTestFunc |
Enumerations | |
enum | ETestUserFuncType { eTestUserFuncInit , eTestUserFuncFini , eTestUserFuncCmdLine , eTestUserFuncVars , eTestUserFuncDeps , eTestUserFuncFirst = eTestUserFuncInit , eTestUserFuncLast = eTestUserFuncDeps } |
Types of functions that user can define. More... | |
Functions | |
void | NcbiTestSetGlobalDisabled (void) |
Disable execution of all tests in current configuration. More... | |
void | NcbiTestSetGlobalSkipped (void) |
Skip execution of all tests in current configuration. More... | |
CNcbiApplication * | NcbiTestGetAppInstance (void) |
Return current application instance. More... | |
CNcbiRegistry & | NcbiTestGetRWConfig (void) |
Wrapper to get the application's configuration parameters, accessible to read-write. More... | |
void | NcbiTestDependsOn (boost::unit_test::test_unit *tu, boost::unit_test::test_unit *dep_tu) |
Mark test case/suite as dependent on another test case/suite. More... | |
void | NcbiTestDisable (boost::unit_test::test_unit *tu) |
Disable test unit. More... | |
void | RegisterNcbiTestUserFunc (TNcbiTestUserFunction func, ETestUserFuncType func_type) |
Registrar of all user-defined functions. More... | |
SNcbiTestUserFuncReg::SNcbiTestUserFuncReg (TNcbiTestUserFunction func, ETestUserFuncType func_type) | |
CExprParser * | NcbiTestGetIniParser (void) |
Get pointer to parser which will be used for evaluating conditions written in configuration file. More... | |
CArgDescriptions * | NcbiTestGetArgDescrs (void) |
Get ArgDescriptions object which will be passed to application for parsing command line arguments. More... | |
boost::unit_test::test_unit * | NcbiTestGetUnit (CTempString test_name) |
Get pointer to test unit by its name which can be partial, i.e. More... | |
SNcbiTestRegistrar::SNcbiTestRegistrar (boost::unit_test::test_case *tc, boost::unit_test::counter_t exp_fail, unsigned int timeout) | |
SNcbiTestRegistrar::SNcbiTestRegistrar (boost::unit_test::test_case *tc, boost::unit_test::counter_t exp_fail) | |
SNcbiTestRegistrar::SNcbiTestRegistrar (boost::unit_test::const_string ts_name) | |
SNcbiTestRegistrar::SNcbiTestRegistrar (boost::unit_test::test_unit_generator const &tc_gen) | |
SNcbiTestRegistrar::SNcbiTestRegistrar (int n) | |
SNcbiTestTCTimeout< T >::SNcbiTestTCTimeout () | |
SNcbiTestTCTimeout< T >::SNcbiTestTCTimeout (unsigned int v) | |
static SNcbiTestTCTimeout *& | SNcbiTestTCTimeout< T >::instance () |
unsigned int | SNcbiTestTCTimeout< T >::value () const |
CNcbiTestParamTestCaseGenerator< ParamType, ParamIter >::CNcbiTestParamTestCaseGenerator (TTestFunc const &test_func, boost::unit_test::const_string name, ParamIter par_begin, ParamIter par_end) | |
virtual | CNcbiTestParamTestCaseGenerator< ParamType, ParamIter >::~CNcbiTestParamTestCaseGenerator () |
virtual boost::unit_test::test_unit * | CNcbiTestParamTestCaseGenerator< ParamType, ParamIter >::next () const |
template<typename ParamType , typename ParamIter > | |
CNcbiTestParamTestCaseGenerator< ParamType, ParamIter > | NcbiTestGenTestCases (typename CNcbiTestParamTestCaseGenerator< ParamType, ParamIter >::TTestFunc const &test_func, boost::unit_test::const_string name, ParamIter par_begin, ParamIter par_end) |
Helper functions to be used in BOOST_PARAM_TEST_CASE macro to create special test case generator. More... | |
template<typename ParamType , typename ParamIter > | |
CNcbiTestParamTestCaseGenerator< typename boost::remove_const< typename boost::remove_reference< ParamType >::type >::type, ParamIter > | NcbiTestGenTestCases (void(*test_func)(ParamType), boost::unit_test::const_string name, ParamIter par_begin, ParamIter par_end) |
static CNcbiTestMemoryCleanupList * | CNcbiTestMemoryCleanupList::GetInstance () |
CNcbiTestMemoryCleanupList::~CNcbiTestMemoryCleanupList () | |
void | CNcbiTestMemoryCleanupList::Add (void *ptr) |
#define NCBITEST_ADD_TEST_CASE | ( | function | ) |
Set of macros to manually add test cases that cannot be created using BOOST_AUTO_TEST_CASE.
To create such test cases you should have a function (that can accept up to 3 parameters) and use one of macros below inside NCBITEST_INIT_TREE() function. All function parameters are passed by value.
Definition at line 965 of file test_boost.hpp.
#define NCBITEST_ADD_TEST_CASE1 | ( | function, | |
param1 | |||
) |
Definition at line 971 of file test_boost.hpp.
#define NCBITEST_ADD_TEST_CASE2 | ( | function, | |
param1, | |||
param2 | |||
) |
Definition at line 977 of file test_boost.hpp.
#define NCBITEST_ADD_TEST_CASE3 | ( | function, | |
param1, | |||
param2, | |||
param3 | |||
) |
Definition at line 983 of file test_boost.hpp.
#define NCBITEST_AUTO_FINI | ( | ) | NCBITEST_AUTOREG_FUNCTION(eTestUserFuncFini) |
Macro for introducing finalization function which will be called after actual tests execution even if only select number of tests will be executed (if command line parameter –run_test=...
were given). The usage of this macro:
NCBITEST_AUTO_FINI() { // finalization function body }
Arbitrary number of finalization functions can be defined. They all will be called after tests are executed but the order of these callings is not defined.
Definition at line 852 of file test_boost.hpp.
#define NCBITEST_AUTO_INIT | ( | ) | NCBITEST_AUTOREG_FUNCTION(eTestUserFuncInit) |
Macro for introducing initialization function which will be called before tests execution and only if tests will be executed (if there's no command line parameter -dryrun or –do_not_test) even if only select number of tests will be executed (if command line parameter –run_test=...
were given). If any of these initialization functions will throw an exception then tests will not be executed. The usage of this macro:
NCBITEST_AUTO_INIT() { // initialization function body }
Arbitrary number of initialization functions can be defined. They all will be called before tests but the order of these callings is not defined.
Definition at line 834 of file test_boost.hpp.
Helper macros for unique identifiers.
Definition at line 1111 of file test_boost.hpp.
#define NCBITEST_AUTOREG_FUNCTION | ( | type | ) |
Definition at line 1116 of file test_boost.hpp.
#define NCBITEST_AUTOREG_HELPER BOOST_JOIN(NcbiTestAutoHelper, __LINE__) |
Definition at line 1114 of file test_boost.hpp.
#define NCBITEST_AUTOREG_OBJ BOOST_JOIN(NcbiTestAutoObj, __LINE__) |
Definition at line 1113 of file test_boost.hpp.
#define NCBITEST_AUTOREG_PARAMFUNC | ( | type, | |
param_decl, | |||
param_func | |||
) |
Definition at line 1122 of file test_boost.hpp.
#define NCBITEST_DEPENDS_ON | ( | test_name, | |
dep_name | |||
) |
Add dependency between test test_name and dep_name.
This dependency means if test dep_name is failed during execution or was disabled by any reason then test test_name will not be executed (will be skipped). To be used inside function introduced by NCBITEST_INIT_TREE.
test_name | Name of the test as a bare text without quotes. Name can exclude test_ prefix if function name includes one and class prefix if it is class member test case. |
dep_name | Name of the test to depend on. Name can be given with the same assumptions as test_name. |
Definition at line 925 of file test_boost.hpp.
Add dependency between test test_name and several other tests which names given in the list dep_names_array.
This dependency means if any of the tests in list dep_names_array is failed during execution or was disabled by any reason then test test_name will not be executed (will be skipped). To be used inside function introduced by NCBITEST_INIT_TREE. Macro is equivalent to use NCBI_TEST_DEPENDS_ON several times for each test in dep_names_array.
test_name | Name of the test as a bare text without quotes. Name can exclude test_ prefix if function name includes one and class prefix if it is class member test case. |
N | Number of tests in dep_names_array |
dep_names_array | Names of tests to depend on. Every name can be given with the same assumptions as test_name. Array should be given enclosed in parenthesis like (test_name1, ..., test_nameN) and should include exactly N elements or preprocessor error will occur during compilation. |
Definition at line 952 of file test_boost.hpp.
#define NCBITEST_DEPENDS_ON_N_IMPL | ( | z, | |
n, | |||
names_array | |||
) |
Helper macro to implement NCBI_TEST_DEPENDS_ON_N.
Definition at line 1040 of file test_boost.hpp.
#define NCBITEST_DISABLE | ( | test_name | ) | NcbiTestDisable(NcbiTestGetUnit(BOOST_STRINGIZE(test_name))) |
Unconditionally disable test case.
To be used inside function introduced by NCBITEST_INIT_TREE.
test_name | Name of the test as a bare text without quotes. Name can exclude test_ prefix if function name includes one and class prefix if it is class member test case. |
Definition at line 906 of file test_boost.hpp.
#define NCBITEST_INIT_CMDLINE | ( | var_name | ) |
Macro for introducing function initializing argument descriptions for tests.
This function will be called before CNcbiApplication will parse command line arguments. So it will parse command line using descriptions set by this function. Also test framework will react correctly on such arguments as -h, -help or -dryrun (the last will just print list of unit tests without actually executing them). The parameter var_name is a name for variable of type CArgDescriptions* that can be used inside function to set up argument descriptions. Usage of this macro is like this:
NCBITEST_INIT_CMDLINE(my_args) { my_args->SetUsageContext(...); my_args->AddPositional(...); }
Definition at line 812 of file test_boost.hpp.
#define NCBITEST_INIT_TREE | ( | ) | NCBITEST_AUTOREG_FUNCTION(eTestUserFuncDeps) |
Macro for introducing function which should initialize dependencies between test units and some hard coded (not taken from configuration file) tests disablings.
All function job can be done by using NCBITEST_DISABLE, NCBITEST_DEPENDS_ON and NCBITEST_DEPENDS_ON_N macros in conjunction with some conditional statements maybe. The usage of this macro:
NCBITEST_INIT_TREE() { NCBITEST_DISABLE(test_name11); NCBITEST_DEPENDS_ON(test_name22, test_name1); NCBITEST_DEPENDS_ON_N(test_name33, N, (test_name1, ..., test_nameN)); }
Arbitrary number of such functions can be defined.
Definition at line 893 of file test_boost.hpp.
#define NCBITEST_INIT_VARIABLES | ( | var_name | ) |
Macro for introducing function which should initialize configuration conditions parser.
This parser will be used to evaluate conditions for running tests written in configuration file. So you should set values for all variables that you want to participate in those expressions. Test framework automatically adds all OS*, COMPILER* and DLL_BUILD variables with the values of analogous NCBI_OS*, NCBI_COMPILER* and NCBI_DLL_BUILD macros. The usage of this macro:
NCBITEST_INIT_VARIABLES(my_parser) { my_parser->AddSymbol("var_name1", value_expr1); my_parser->AddSymbol("var_name2", value_expr2); }
Arbitrary number of such functions can be defined.
Definition at line 870 of file test_boost.hpp.
typedef void(* TNcbiTestUserFunction) (void) |
Type of user-defined function which will be automatically registered in test framework.
Definition at line 1069 of file test_boost.hpp.
typedef boost::unit_test::ut_detail::auto_test_unit_registrar SNcbiTestRegistrar::TParent |
Definition at line 1137 of file test_boost.hpp.
typedef boost::unit_test::callback1<ParamType> CNcbiTestParamTestCaseGenerator< ParamType, ParamIter >::TTestFunc |
Definition at line 1222 of file test_boost.hpp.
enum ETestUserFuncType |
Types of functions that user can define.
Enumerator | |
---|---|
eTestUserFuncInit | |
eTestUserFuncFini | |
eTestUserFuncCmdLine | |
eTestUserFuncVars | |
eTestUserFuncDeps | |
eTestUserFuncFirst | |
eTestUserFuncLast |
Definition at line 1072 of file test_boost.hpp.
void CNcbiTestMemoryCleanupList::Add | ( | void * | ptr | ) |
Definition at line 929 of file test_boost.cpp.
References CNcbiTestMemoryCleanupList::m_List.
|
inline |
Definition at line 1225 of file test_boost.hpp.
References CNcbiTestParamTestCaseGenerator< ParamType, ParamIter >::m_Name.
|
static |
Definition at line 913 of file test_boost.cpp.
References s_TestMemoryCleanupList.
|
inlinestatic |
Definition at line 1194 of file test_boost.hpp.
Referenced by SNcbiTestTCTimeout< T >::SNcbiTestTCTimeout().
void NcbiTestDependsOn | ( | boost::unit_test::test_unit * | tu, |
boost::unit_test::test_unit * | dep_tu | ||
) |
Mark test case/suite as dependent on another test case/suite.
If dependency test case didn't executed successfully for any reason then dependent test will not be executed. This rule has one exception: if test is requested to execute in command line via parameter "--run_test" and dependency was not requested to execute, requested test will be executed anyways.
tu | Test case/suite that should be marked as dependent |
dep_tu | Test case/suite that will be "parent" for tu |
void NcbiTestDisable | ( | boost::unit_test::test_unit * | tu | ) |
Disable test unit.
Disabled test unit will not be executed (as if p_enabled is set to false) but it will be reported in final Boost.Test report as disabled (as opposed to setting p_enabled to false when test does not appear in final Boost.Test report).
|
inline |
Helper functions to be used in BOOST_PARAM_TEST_CASE macro to create special test case generator.
Definition at line 1276 of file test_boost.hpp.
|
inline |
Definition at line 1290 of file test_boost.hpp.
References type.
CNcbiApplication* NcbiTestGetAppInstance | ( | void | ) |
Return current application instance.
Similar to CNcbiApplication::Instance().
Definition at line 2192 of file test_boost.cpp.
Referenced by NCBITEST_AUTO_INIT().
CArgDescriptions* NcbiTestGetArgDescrs | ( | void | ) |
Get ArgDescriptions object which will be passed to application for parsing command line arguments.
Definition at line 2209 of file test_boost.cpp.
CExprParser* NcbiTestGetIniParser | ( | void | ) |
Get pointer to parser which will be used for evaluating conditions written in configuration file.
Definition at line 2203 of file test_boost.cpp.
CNcbiRegistry& NcbiTestGetRWConfig | ( | void | ) |
Wrapper to get the application's configuration parameters, accessible to read-write.
We cannot use CNcbiApplication::GetConfig(), because it return read-only registry, and protected CNcbiApplication::GetRWConfig() is not accessible for unit tests directly.
Definition at line 2197 of file test_boost.cpp.
Referenced by BOOST_AUTO_TEST_CASE(), CAutoNcbiConfigFile::CAutoNcbiConfigFile(), and NCBITEST_AUTO_INIT().
boost::unit_test::test_unit* NcbiTestGetUnit | ( | CTempString | test_name | ) |
Get pointer to test unit by its name which can be partial, i.e.
without class prefix and/or test_ prefix if any. Throws an exception in case of name of non-existent test
Definition at line 2215 of file test_boost.cpp.
void NcbiTestSetGlobalDisabled | ( | void | ) |
Disable execution of all tests in current configuration.
Call to the function is equivalent to setting GLOBAL = true in ini file. Globally disabled tests are shown as DIS by check scripts (called via make check). Function should be called only from NCBITEST_AUTO_INIT() or NCBITEST_INIT_TREE() functions.
Definition at line 2181 of file test_boost.cpp.
void NcbiTestSetGlobalSkipped | ( | void | ) |
Skip execution of all tests in current configuration.
Globally skipped tests are shown as SKP by check scripts (called via make check). Function should be called only from NCBITEST_AUTO_INIT() or NCBITEST_INIT_TREE() functions.
Definition at line 2187 of file test_boost.cpp.
|
inlinevirtual |
Definition at line 1240 of file test_boost.hpp.
References NStr::IntToString(), CNcbiTestParamTestCaseGenerator< ParamType, ParamIter >::m_CaseIndex, CNcbiTestParamTestCaseGenerator< ParamType, ParamIter >::m_Name, CNcbiTestParamTestCaseGenerator< ParamType, ParamIter >::m_ParBegin, CNcbiTestParamTestCaseGenerator< ParamType, ParamIter >::m_ParEnd, CNcbiTestParamTestCaseGenerator< ParamType, ParamIter >::m_TestFunc, and NULL.
void RegisterNcbiTestUserFunc | ( | TNcbiTestUserFunction | func, |
ETestUserFuncType | func_type | ||
) |
Registrar of all user-defined functions.
Definition at line 2162 of file test_boost.cpp.
Referenced by SNcbiTestUserFuncReg::SNcbiTestUserFuncReg().
|
inlineexplicit |
Definition at line 1164 of file test_boost.hpp.
|
inline |
Definition at line 1157 of file test_boost.hpp.
|
inline |
Definition at line 1139 of file test_boost.hpp.
|
inlineexplicit |
Definition at line 1170 of file test_boost.hpp.
|
inlineexplicit |
Definition at line 1175 of file test_boost.hpp.
|
inline |
Definition at line 1186 of file test_boost.hpp.
|
inlineexplicit |
Definition at line 1188 of file test_boost.hpp.
References SNcbiTestTCTimeout< T >::instance().
|
inline |
Definition at line 1089 of file test_boost.hpp.
References RegisterNcbiTestUserFunc().
|
inline |
Definition at line 1202 of file test_boost.hpp.
References SNcbiTestTCTimeout< T >::m_value.
CNcbiTestMemoryCleanupList::~CNcbiTestMemoryCleanupList | ( | ) |
Definition at line 921 of file test_boost.cpp.
References free(), CNcbiTestMemoryCleanupList::m_List, and s_TestMemoryCleanupList.
|
inlinevirtual |
Definition at line 1238 of file test_boost.hpp.
|
extern |
Definition at line 162 of file test_boost.cpp.
|
mutableprivate |
Definition at line 1268 of file test_boost.hpp.
Referenced by CNcbiTestParamTestCaseGenerator< ParamType, ParamIter >::next().
|
private |
Definition at line 1317 of file test_boost.hpp.
Referenced by CNcbiTestMemoryCleanupList::Add(), and CNcbiTestMemoryCleanupList::~CNcbiTestMemoryCleanupList().
|
private |
Definition at line 1265 of file test_boost.hpp.
Referenced by CNcbiTestParamTestCaseGenerator< ParamType, ParamIter >::CNcbiTestParamTestCaseGenerator(), and CNcbiTestParamTestCaseGenerator< ParamType, ParamIter >::next().
|
mutableprivate |
Definition at line 1266 of file test_boost.hpp.
Referenced by CNcbiTestParamTestCaseGenerator< ParamType, ParamIter >::next().
|
private |
Definition at line 1267 of file test_boost.hpp.
Referenced by CNcbiTestParamTestCaseGenerator< ParamType, ParamIter >::next().
|
private |
Definition at line 1264 of file test_boost.hpp.
Referenced by CNcbiTestParamTestCaseGenerator< ParamType, ParamIter >::next().
|
private |
Definition at line 1206 of file test_boost.hpp.
Referenced by SNcbiTestTCTimeout< T >::value().