use test_name rather than __LINE__ for hidden test structs
When building tests from mutliple files together, the line number the test is declared on is not guaranteed to be unique. If two tests happen to be on the same line, one of them will not be run. You will then go crazy trying to figure out why seemingly unrelated changes make the problem go away.
This commit is contained in:
parent
29ba738876
commit
2d9cf0f8b3
|
@ -88,8 +88,8 @@ extern int EXPORT _g_test_failures;
|
|||
|
||||
#define TORRENT_TEST(test_name) \
|
||||
static void BOOST_PP_CAT(unit_test_, test_name)(); \
|
||||
static struct BOOST_PP_CAT(register_class, __LINE__) { \
|
||||
BOOST_PP_CAT(register_class, __LINE__) () { \
|
||||
static struct BOOST_PP_CAT(register_class_, test_name) { \
|
||||
BOOST_PP_CAT(register_class_, test_name) () { \
|
||||
unit_test_t& t = _g_unit_tests[_g_num_unit_tests]; \
|
||||
t.fun = &BOOST_PP_CAT(unit_test_, test_name); \
|
||||
t.name = __FILE__ "." #test_name; \
|
||||
|
@ -98,7 +98,7 @@ extern int EXPORT _g_test_failures;
|
|||
t.output = NULL; \
|
||||
_g_num_unit_tests++; \
|
||||
} \
|
||||
} BOOST_PP_CAT(_static_registrar, __LINE__); \
|
||||
} BOOST_PP_CAT(_static_registrar_, test_name); \
|
||||
static void BOOST_PP_CAT(unit_test_, test_name)()
|
||||
|
||||
#define TEST_REPORT_AUX(x, line, file) \
|
||||
|
|
Loading…
Reference in New Issue